-
Notifications
You must be signed in to change notification settings - Fork 251
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
Apollo Federation gateway breaks upon receiving a query with empty variables section #300
Comments
Hi @rahul22048, can you please provide a runnable reproduction and version info for this issue? I've tried in multiple ways to not provide a I'm mostly interested in how you're going about calling the gateway and at which location in the API your initiating execution. Currently, with a gateway running inside of Apollo Server (as is our typical configuration), I can send a query from await server.executeOperation({
query: `query { products { id } }`,
}); ...with no |
@trevor-scheer :- I am not sure which client side library you are using. Just to make sure, can u confirm that the actual network request which is going, in that variables section is empty. We are using 0.20.0 version of @apollo/gateway library. |
@rahul22048 no client library, my request was handwritten and sent via curl -X POST localhost:4000 -H "content-type: application/json" --data "{ \"query\": \"{ products { id } }\" }" Please send a reproduction if you'd like for me to look into this further. |
@trevor-scheer :- Upon digging into this issue , the issue was with the way query was written. In case queries have input variables, and you specify the default value inline , without explicitly passing variables , then it fails. For ex:- query getPosts($size:Int = 50) { In the above example i have not passed explicit variables section, instead specified values in line, the query fails. if i would have written the same query in following way:- query getPosts($size:Int) { The issue is the first query was working without federation gateway in between. To me to make the behaviour compatible with apollo server, i think federation gateway should also accept first type of queries. |
I can reproduce this issue with this codesandbox Run the following query. With variables, it runs. With no variables it errors out query ExampleIncludeDefault($toInclude: Boolean = true) {
topProducts {
name
price @include(if: $toInclude)
}
} |
Apollo federation gateway breaks throwing
Cannot convert undefined or null to object
upon receiving a graphql query which does not have any variables section. (From our perspective this is a very common use case).Passing variables as empty object {}, works fine, but it should not be mandated on the caller to explicitly pass empty object.
The text was updated successfully, but these errors were encountered: