Skip to content

Get nodes created by plugin by their type #26

Open
@snussik

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions