-
Notifications
You must be signed in to change notification settings - Fork 20
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
xgql does not deduplicate query keys #78
Comments
I tried this with 99designs/gqlgen@5ad012e, which is the latest commit in master at the time of writing. It appears to fix the problem of returning duplicate keys, but it does so by having the inline fragment override the more generic part of the query rather than merging them. That is, if I query: query {
kubernetesResource(
id: "Xf5rXAL-UHvndETH56dPJgA5XXvndEQ5PV9DOf4zbf43O1X_Bzg1MDkxNzM"
) {
metadata {
name
}
}
} I get this response: {
"data": {
"kubernetesResource": {
"metadata": {
"name": "crossplane-provider-aws-3b7ef8509173"
}
}
},
"extensions": {}
} However if I query: query {
kubernetesResource(
id: "Xf5rXAL-UHvndETH56dPJgA5XXvndEQ5PV9DOf4zbf43O1X_Bzg1MDkxNzM"
) {
metadata {
name
}
...on ProviderRevision {
metadata {
uid
}
}
}
} I get: {
"data": {
"kubernetesResource": {
"metadata": {
"uid": "3c3d2f11-cf1a-4f49-8e53-88a1110a352c"
}
}
},
"extensions": {}
} |
I presume the above behaviour is not intended and is still a bug in gqlgen, because this query merges the query {
kubernetesResource(
id: "Xf5rXAL-UHvndETH56dPJgA5XXvndEQ5PV9DOf4zbf43O1X_Bzg1MDkxNzM"
) {
metadata {
name
}
metadata {
uid
}
}
} |
I've raised 99designs/gqlgen#1547 to track this. |
It's far from ideal, but I wonder whether it's possible to work around the "new" version of this bug (i.e. where inline fragments override less specific queries) by duplicating the information we want inside inline fragments. For example: query {
kubernetesResource(
id: "Xf5rXAL-UHvndETH56dPJgA5XXvndEQ5PV9DOf4zbf43O1X_Bzg1MDkxNzM"
) {
metadata {
name
}
...on ProviderRevision {
metadata {
# We duplicate name here to make sure it's always returned.
name
uid
}
}
}
} |
Our use of xgql is through a stitching layer that auto-generates fragments. Not having control of these fragments is why this and the original bug are hard to deal with. At least with the original bug the data was in the payload, just spread among duplicate keys. In this new bug they data is just missing. |
A fix for this has now been merged to gqlgen, but not yet released. Once they get their next release out we should bump it and ship a fixed release of xgql. @thephred will we have any workarounds (e.g. in upbound-graphql) that we'll need to remove? |
Normally we'd wait for a release, but I don't know when the next one is due and master has a fix for upbound#78. Signed-off-by: Nic Cope <negz@rk0n.org>
Normally we'd wait for a release, but I don't know when the next one is due and master has a fix for upbound#78. Signed-off-by: Nic Cope <negz@rk0n.org>
What happened?
Yields this:
Which is invalid JSON and should yield this:
This may be related 99designs/gqlgen#1311.
How can we reproduce it?
Make the query above.
What environment did it happen in?
The text was updated successfully, but these errors were encountered: