-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Nondeterministic output when query and subscription return (non)nullable list elements #896
Comments
I have the exact some issue. |
The template creating the code line that flips is codegen/type.gotpl L93. Then we head to MarshalFunc then to UniquenessKey: func (t *TypeReference) UniquenessKey() string {
var nullability = "O"
if t.GQL.NonNull {
nullability = "N"
}
return nullability + t.Definition.Name + "2" + templates.TypeIdentifier(t.GO)
} Let's see what's happening with |
PR #900 should fix this. |
Pretty sure I am running into this too. Thanks for the PR @zannen. |
vektah
added a commit
that referenced
this issue
Nov 11, 2019
Update UniquenessKey for when Element is/isn't nullable (#896)
Thanks @vektah. |
cgxxv
pushed a commit
to cgxxv/gqlgen
that referenced
this issue
Mar 25, 2022
With a schema: type Query { things1: [Thing] # Note the lack of "!" } type Subscription { things2: [Thing!] # Note the "!" } the UniquenessKey for the two lists is the same, which causes non-deterministic output.
cgxxv
pushed a commit
to cgxxv/gqlgen
that referenced
this issue
Mar 25, 2022
cgxxv
pushed a commit
to cgxxv/gqlgen
that referenced
this issue
Mar 25, 2022
cgxxv
pushed a commit
to cgxxv/gqlgen
that referenced
this issue
Mar 25, 2022
cgxxv
pushed a commit
to cgxxv/gqlgen
that referenced
this issue
Mar 25, 2022
cgxxv
pushed a commit
to cgxxv/gqlgen
that referenced
this issue
Mar 25, 2022
cgxxv
pushed a commit
to cgxxv/gqlgen
that referenced
this issue
Mar 25, 2022
Update UniquenessKey for when Element is/isn't nullable (99designs#896)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With the schema below, output is nondeterministic.
This behaviour occurs when a query returns a list of nullable things and a subscription returns a list of non-nullable things (or vice versa), the generated code for the subscription (it seems to always be the subscription) flips between using the normal function (
marshalOThing2ᚖgqlgentestᚐThing
) and the function with the null check (marshalNThing2ᚖgqlgentestᚐThing
).This behaviour does not occur:
[Thing]
and one returning[Thing!]
[Thing]
and one returning[Thing!]
Thing
is replaced byString
What did you expect?
Deterministic output.
Minimal graphql.schema to reproduce
gqlgen.yml
Here's the script I've been using to test. Run it and wait for a while to see if files with different checksums get created.
versions
gqlgen version
v0.10.1go version
go1.11.13 linux/amd64go.mod
The text was updated successfully, but these errors were encountered: