Reference Equality Check in VariableTypesMatchRule breaks if GraphQLInputObjectType is created multiple times.
See original GitHub issueNormally in schema creation, it is OK to create multiple instances of the same type object. However, VariableTypesMatchRule
uses reference equality, so if I create my schema with multiple instances of an equivalent GraphQLObjectInputType
then I will get validation failures. This was tricky to track down because I create input types in methods (e.g. private GraphQLInputObjectType createPropertyMatchType()
) and then call those methods when I need it them.
I think the ideal solution is to use deep equality instead of reference equality in VariableTypeMatchRule
.
Otherwise some process in schema creation should canonicalize the types within the schema.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:26 (21 by maintainers)
Top Results From Across the Web
How to test for reference equality (Identity) - C# guide
The following example shows how to determine whether two variables have reference equality, which means that they refer to the same object ...
Read more >Scala match and reference equality check - Stack Overflow
1 Answer 1 ... There is a contract for equals . x.equals(x) has to be true. If you break that contract, a lot...
Read more >Index (graphql-java 230521-nf-execution API) - Javadoc.io
A factory method for creating asynchronous data fetchers so that when used with ... Can be called multiple times to change the current...
Read more >Reading 15: Equality - MIT
Understand equality defined in terms of the abstraction function, an equivalence relation, and observations. Differentiate between reference equality and object ...
Read more >Equality (==) - JavaScript - MDN Web Docs
The equality (==) operator checks whether its two operands are equal, returning a Boolean result. Unlike the strict equality operator, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Right: they must be equal according to the spec. But what if due to say, a bug, they are not?
Say I have one spot in my code where I have:
and another where:
then, say, in some other code I compare these definitions and the result is they are equivalent. Then how much longer down the line will this bug manifest?
My point is—and sorry truly if I am missing something or am just being too pedantic—that yes, the spec says a type’s name should be unique. But from a runtime Java perspective, two object definitions with the same name can be totally different, and the usefulness of an equivalence relation that only compares their names seems, well, not useful, and even worse, bug prone?
Nothing is stopping them to do so. What we can do is to refuse adding two unequal types with the same name to the schema, proactively, so this type of mistake can be caught early.
On Friday, 6 May 2016, danielkwinsor notifications@github.com wrote:
Y.