question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GraphQL Input Object parsed differently when Query Variable is used

See original GitHub issue

Hi there.

My team and I have been scratching our heads on this one for awhile and (mostly) blaming Firebase (hard not to sometimes). But today we observed something that shows a clear difference in how GraphQL Input Objects are parsed in an Apollo GraphQL resolver depending on whether Query Variables are used or not.

I put a full description and screenshots with an easy app to clone and run at the github URL below.

Thanks.


package: It’s hard to tell which package is responsible, but searching through the Apollo code packages for instances of Object.create(null) shows most all of the hits in apollo-server. It’s possible the underlying cause is in one of the core or utils packages though.

expected behavior: Setting an Input Object via Query Variables behaves the same as if are manually entering all those fields in the Input Object portion of the GraphQL query/mutation (without query variable interpolation).

actual behavior: Manually setting the fields in an Input Object (without using a query variable) causes the Input Object to be treated like a dictionary (ie Object.create(null)) where all Object prototype methods used on it throw an error

reproduction: https://github.com/arizonatribe/apollo-graphql-input-object-bug


Works when you build the query’s Input Object by using a query variable:

Works when using Query variables

Does not work when you build the query’s Input Object is without using any query variables:

Does NOT work when Input Object is built without Query variables

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:26 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
glassercommented, Jul 8, 2022

I mean, yes, it it literally is not our problem. I think folks who have run into this problem and are finding it a direct challenge to their work are best equipped to file an issue explaining why it is a problem, rather than us as a third party.

3reactions
robross0606commented, Jul 8, 2022

I suppose we could make a copy of every single issue in https://github.com/nodejs/node in this repository as well, since all of them may affect people who run Apollo Server on Node, but I don’t think that would help.

@glasser, again, the sarcasm is 100% unhelpful and counter-productive. If you can’t have a civilized disagreement with someone, then please stop replying.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mutations and Input Types - GraphQL
But in many cases, you will find a number of different mutations that all accept the same input parameters. A common example is...
Read more >
GraphQL query best practices
If two otherwise identical queries have different hardcoded argument values, they're considered entirely different operations by your GraphQL server's cache.
Read more >
Input object type as an argument for GraphQL mutations and ...
Passing variables as an input object type. ... GraphQL is a query language, which can be used with different languages like Javascript, C#,...
Read more >
How to use GraphQL variables to give queries type safety
Click on the query variables pane at the bottom of the GraphiQL explorer. Create an object, and add your stringified variable name and...
Read more >
GraphQl variable using grapiql - variable is undefined
Any variables used inside an operation must be declared as part of the operation definition, like this: query ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found