You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When graphql type A is a subset of B, then B can be "converted" to A, and look like an A in the graphql response to a query. This is because graphql types is represented as interfaces in go, and it is a feature that a type struct b {} can act as both an A and a B if it satisfies both those interfaces.
{"data": {"node": {"name": "Jon Jonsen","id": "QWRtaW46MQ=="// id: "Admin:1"// no userSpecific field, because this is an Admin now}}}
I circumvented the problem by adding a dummy field to the graphql types that fell victim to this .. well, it is a feature, but for our purposes it's a bug.
My new graphql schema:
typeAdminextendsNode {
id: ID!
name: String!
# Do not consume this field /// Document that this field is not part of apiisAdmin: Bool
}
typeUserextendsNode {
id: ID!
name: String!
userSpecific: Bool # Do not consume this field /// Also hereisUser: Bool
}
Thanks to @noh4ck for helping me finding the cause and a workaround.
The text was updated successfully, but these errors were encountered:
When graphql type
A
is a subset ofB
, thenB
can be "converted" toA
, and look like anA
in the graphql response to a query. This is because graphql types is represented as interfaces in go, and it is a feature that atype struct b {}
can act as both anA
and aB
if it satisfies both those interfaces.Let me explain.
Graphql schema:
From this,
granate
generates interfaces:The important thing here is that anything that satisfies
UserInterface
also satisfies theAdminInterface
which tricks the following logic:This means that this GraphQL request
returns this response
I circumvented the problem by adding a dummy field to the graphql types that fell victim to this .. well, it is a feature, but for our purposes it's a bug.
My new graphql schema:
Thanks to @noh4ck for helping me finding the cause and a workaround.
The text was updated successfully, but these errors were encountered: