You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arguments in a graphQL query don't work when using schema customization.
After watching the learn with Jason stream on advanced GraphQL(broken up in multiple parts due to technical difficulties) I incorporated a lot of what was talked about into my theme.
However using graphQL arguments (like filter and sort) that rely on values from the customized schema doesn't work.
Steps to reproduce
run this branch of my theme locally.
Fire up /___graphql and query allBlogPosts.
Now try to query allBlogPosts again with a sort by descending date.
RESULT: no change in order (ASC, or DESC)
Example 2
Query for all posts and show their titles.
query MyQuery {
allBlogPost {
nodes {
title
}
}
}
RESULT: works
now query for all posts that are have a tag with slug "lorem-ipsum"
It seems like the graphql arguments use data from the MdxBlogPost node rather than the eventual result after it runs its resolvers. Is my suspicion close?
Relevant parts of code are in gatsby-node.js in the theme directory.
specifically the createSchemaCustomization and onCreateNode lifecycles.
I tried to heavily comment to show my though process.
edit: should have posted this in #12272 instead of as seperate issue. Closing this in favor of a comment there.
The text was updated successfully, but these errors were encountered:
Description
Arguments in a graphQL query don't work when using schema customization.
After watching the learn with Jason stream on advanced GraphQL(broken up in multiple parts due to technical difficulties) I incorporated a lot of what was talked about into my theme.
However using graphQL arguments (like filter and sort) that rely on values from the customized schema doesn't work.
Steps to reproduce
run this branch of my theme locally.
Fire up /___graphql and query allBlogPosts.
Now try to query allBlogPosts again with a sort by descending date.
RESULT: no change in order (ASC, or DESC)
Example 2
Query for all posts and show their titles.
RESULT: works
now query for all posts that are have a tag with slug "lorem-ipsum"
RESULT: empty nodes array.
temporary workaround, possible reason why it doesn't work?
Try to query a single BlogPost (picks first one by default if no arguments are given).
Now try to query
blogPost(slug: {eq: "herp-derpsum"})
.This works, I think because I added the slug to the MdxBlogPost node.
https://github.com/NickyMeuleman/gatsby-theme-nicky-blog/blob/d29c966e639f4733caf9ee43e9f5755df42db71d/theme/gatsby-node.js#L209-L210
It seems like the graphql arguments use data from the MdxBlogPost node rather than the eventual result after it runs its resolvers. Is my suspicion close?
Environment
System:
OS: Linux 4.19 Ubuntu 18.04.2 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz
Shell: 4.4.19 - /bin/bash
Binaries:
Node: 12.4.0 - /tmp/yarn--1565124765846-0.45931526383359134/node
Yarn: 1.16.0 - /tmp/yarn--1565124765846-0.45931526383359134/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v12.4.0/bin/npm
Languages:
Python: 2.7.15+ - /usr/bin/python
Additional notes
Relevant parts of code are in
gatsby-node.js
in the theme directory.specifically the
createSchemaCustomization
andonCreateNode
lifecycles.I tried to heavily comment to show my though process.
edit: should have posted this in #12272 instead of as seperate issue. Closing this in favor of a comment there.
The text was updated successfully, but these errors were encountered: