Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

siteSearchIndex not show - resolver problem in config #28

Open
D19cannon opened this issue Jan 8, 2020 · 0 comments
Open

siteSearchIndex not show - resolver problem in config #28

D19cannon opened this issue Jan 8, 2020 · 0 comments

Comments

@D19cannon
Copy link

D19cannon commented Jan 8, 2020

Hey guys,

I am having this problem for a while and I have been checking every issue that is out there, including the one that are exactly the same as mine, but didn't work.

Basically, I am using the gatsby-source-wordpress plugin with elasticlunr. According to the documentation it should be rather easy. But I guess the following error is explaning that the resolver type is incorrect:

 ERROR #11321  PLUGIN

"@gatsby-contrib/gatsby-plugin-elasticlunr-search" threw an error while running the onCreateNode lifecycle:

Cannot read property 'tags' of undefined

  127 |   }
  128 |
> 129 |   if (filter && !filter(node, getNode)) {
      |                  ^
  130 |     return;
  131 |   }
  132 |

File: node_modules/@gatsby-contrib/gatsby-plugin-elasticlunr-search/gatsby-node.js:129:18

I check all the answers and most people who are using the wordpress plugin are doing exactly the same as me.


module.exports = {
  siteMetadata: {
    title: `wp-gatsby template`,
    description: `wp-gatsby template`,
    author: `D19cannon`,
  },
  plugins: [
    `gatsby-plugin-lint-queries`,
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    // Setup WPGraphQL.com to be the source
    {
      resolve: `gatsby-source-graphql`,
      options: {
        // This type will contain remote schema Query type
        typeName: `WPGraphQL`,
        // This is field under which it's accessible
        fieldName: `wpgraphql`,
        // Url to query from
        url: `http://wp.test/graphql`,
      },
    },
    {
      resolve: 'gatsby-source-wordpress',
      options: {
        baseUrl: 'wp.test/',
        // WP.com sites set to true, WP.org set to false
        hostingWPCOM: false,
        protocol: 'http',
        // Use 'Advanced Custom Fields' Wordpress plugin
        useACF: true,
        auth: {},
        // Set to true to debug endpoints on 'gatsby build'
        verboseOutput: true,
      },
    {
      resolve: `@gatsby-contrib/gatsby-plugin-elasticlunr-search`,
      options: {
        // Fields to index
        fields: [`title`],
        // How to resolve each field`s value for a supported node type
        resolvers: {
          wordpress__PAGE: {
            title: node => node.title,
          },
          wordpress__POST: {
            title: node => node.title,
          },
        },
        // Optional filter to limit indexed nodes
        filter: (node, getNode) =>
          node.frontmatter.tags !== 'exempt',
      },
    },
  ],
}

Let me know what the fields are suppose to be other than 'wordpress__POST'
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant