-
Notifications
You must be signed in to change notification settings - Fork 25
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
Pass getNode to custom resolver functions #3
Conversation
Hi, thanks for this detailed use case. Could you please provide a way to document this on the repo, maybe extending the example on the readme with a link to this PR. |
Hey @benjaminabel, thanks for the quick reply. Yeah sure can do 👍 |
Thanks for your contribution @jsanchez034. |
Thank you @benjaminabel ! 😃 |
Oh @benjaminabel one question, what is your process for publishing the module to NPM? Is that something I can do? |
Just published it. |
Thank you! |
@benjaminabel looks like new module version did not build latest source code. I'm not seeing the new param being passed into custom resolver |
I did forgot to build the package before publishing. npm prepublish comes to the rescue.
|
So how does this work for collections? (Pretty new to Gatsby and GraphQL, so bear with me.) Your example of
assumes that there's only one image. What if it's |
Any reply for this question above? |
Currently if you have a content model that has nested models (see
featuredImage
field below) you need to resolve all the nested models and then query the nested model in userland code to build a proper model with all the data you require. This makes the elasticlunr search index JSON potentially very large and the search logic more complicated ...Imagine in the above scenario you have 1,000
ContentfulBlogPost
models and 50,0000ContentfulAsset
models. The search index will contain 51,000 items when it really could contain 1,000 items that are a little larger given the nestedfeaturedImage
model.This change passes the
getNode
function to all resolvers so that a user of this plugin can use thegetNode
function in there custom resolvers and avoid bloating there elasticlunr search index JSON...