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

Get nodes created by plugin by their type #26

Open
snussik opened this issue Dec 23, 2020 · 0 comments
Open

Get nodes created by plugin by their type #26

snussik opened this issue Dec 23, 2020 · 0 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@snussik
Copy link

snussik commented Dec 23, 2020

If I explore data, created by plugin, I can find:

postgres (PostGraphile) {
    allElements (PostGraphile_ElementsConnection) {
      nodes (PostGraphile_Element) {
        ....
      }
    }
  }

And I even can modify these nodes like this:

exports.createResolvers = ({ createResolvers }) => {
    createResolvers({
    PostGraphile_Element: {
    internal: {
        type: `Internal`,
        resolve: object => {
            return {
                type: `pgData`,
            }
        }
    }
  },
});
}

But if I try to use this node in other places with constructions:

if (node.internal.type === `pgData`) {
       // do smth..
    }
const nodes =  getNodesByType(`pgData`)) || getNodesByType(`PostGraphile_Element`)) 

I get nothing.

So, If I want to build lunr index from nodes with lunr-plugin I try to use such syntax, as described in its rtfm for gatsby-config.js:

{
    resolve: `@gatsby-contrib/gatsby-plugin-elasticlunr-search`,
    options: {
      fields: [`name`],
      // How to resolve each field`s value for a supported node type
      resolvers: {
        PostGraphile_Element: {
        name: node => node.name,
        }, 
        // Or try to use my crated internal.type:
        pgData: {
          name: node => node.name,
        },
      },
    },
  },

The question is for I can get created child nodes by their type PostGraphile_Element or pgData

@benjie benjie added help wanted Extra attention is needed question Further information is requested labels Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants