-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Validate GraphQL queries in gatsby-node.js with Relay Compiler #1689
Comments
We use the Relay Compiler to validate queries in pages so we get more warnings there. Would like to do the same validation for queries written elsewhere e.g. in gatsby-node.js |
Updated the issue title to reflect this :-) |
Just sharing this announcement about a new GraphQL tool |
I ran into this problem as well when trying to get a list of all blog posts without the static pages ("about me", etc.) Here's the query: {
allMarkdownRemark(filter:{ frontmatter: { date: { ne: null }}}) {
edges {
node {
frontmatter {
title
date
}
}
}
}
} This works as expected in GraphiQL, but returns the |
I'm not sure actually where the |
I think you're right. As best as I can tell, the error seems to be coming from the Relay compiler, from this block: gatsby/packages/gatsby/src/internal-plugins/query-runner/query-compiler.js Lines 123 to 131 in f8956a6
Tracking it down in the Relay source, it looks like This switch statement doesn't contain a case for ...
switch (ast.kind) {
case 'NullValue':
return {
kind: 'Literal',
metadata: null,
value: null
};
...
} The error no longer occurs, and the query runs as expected. I'm not very familiar with the inner-workings of GraphQL and Relay, but it seems like this is an issue in Relay instead, right? |
Will be keen to know how this pans out, as I tried the same thing today and having to work around it at the moment by ensuring my data has no null paths!! However there are occasions where I may wish to set them as null, for example, to signify that they are not "published" |
Summary: Hi there! This patch is the result of debugging gatsbyjs/gatsby#1689. It seems like the switch statement inside of `RelayParser._transformValue()` was missing a case for `NullValue`, so queries which contained a `null` literal would throw an error. Adding a case fixes the downstream issue that some folks have experienced with Gatsby, but I'm not sure if there's a better way to solve this problem. Closes #2035 Reviewed By: leebyron Differential Revision: D5650583 Pulled By: kassens fbshipit-source-id: 9e76f553b35ab106711930150045d285670d36e2
For those finding this outside of gatsby, the issues has been fixed and merged into relay and realy-compiler ^1.3.0 |
Sweet! Thanks @nkohari for fixing the bug upstream!! |
If I put in a page template graphql filter like:
it throws an error
Unknown ast kind: NullValue
But it works in thegatsby-node.js
withcreatePages
methodThe text was updated successfully, but these errors were encountered: