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
We have a DGS with a GraphQL schema that has two possible type of User - AnonUser and RegisteredUser. Both can have a firstName or a lastName but this is non-nullable for RegisteredUser. When sending a request to the DGS to retrieve the current user (this uses the authentication header) it returns either a AnonUser or RegisteredUser. However we get a conflicting types error when using GraphQL Mesh.
If our schema looks like this:
type Query {
_sdl: String!
_appVersion: String!
me: User
}
interface User {
id: ID!
firstName: String
lastName: String
}
type AnonUser implements User {
id: ID!
firstName: String
lastName: String
}
type RegisteredUser implements User {
id: ID!
firstName: String!
lastName: String!
}
When we send it the following request directly we get the user back:
query myUser {
me {
id
firstName
lastName
__typename
}
}
This is also what is sent down via our customer GraphQL Gateway we have created using GraphQL Tools. However, if we send the request through GraphQL Mesh we get the following error messages: Fields \"firstName\" conflict because they return conflicting types \"String\" and \"String!\". Use different aliases on the fields to fetch both if this was intentional. Fields \"lastName\" conflict because they return conflicting types \"String\" and \"String!\". Use different aliases on the fields to fetch both if this was intentional.
After some investigating we found that GraphQL Mesh was sending the following to our DGS:
query myUser {
me {
__typename
... on AnonUser {
id
firstName
lastName
}
... on RegisteredUser {
id
firstName
lastName
}
}
}
Why does GraphQL Mesh change the query like this? I don't think inline fragments need to be used for this query. Then again, I don't know why GraphQL errors as I thought String and String! were compatible types. Could you assist with this? Is this an edge case that needs fixing in GraphQL Mesh?
Also, if you know of a workaround using transforms we can use in the meantime that would be fantastic. Have a nice weekend :)
The text was updated successfully, but these errors were encountered:
We have a DGS with a GraphQL schema that has two possible type of User - AnonUser and RegisteredUser. Both can have a firstName or a lastName but this is non-nullable for RegisteredUser. When sending a request to the DGS to retrieve the current user (this uses the authentication header) it returns either a AnonUser or RegisteredUser. However we get a conflicting types error when using GraphQL Mesh.
If our schema looks like this:
When we send it the following request directly we get the user back:
This is also what is sent down via our customer GraphQL Gateway we have created using GraphQL Tools. However, if we send the request through GraphQL Mesh we get the following error messages:
Fields \"firstName\" conflict because they return conflicting types \"String\" and \"String!\". Use different aliases on the fields to fetch both if this was intentional.
Fields \"lastName\" conflict because they return conflicting types \"String\" and \"String!\". Use different aliases on the fields to fetch both if this was intentional.
After some investigating we found that GraphQL Mesh was sending the following to our DGS:
Why does GraphQL Mesh change the query like this? I don't think inline fragments need to be used for this query. Then again, I don't know why GraphQL errors as I thought String and String! were compatible types. Could you assist with this? Is this an edge case that needs fixing in GraphQL Mesh?
Also, if you know of a workaround using transforms we can use in the meantime that would be fantastic. Have a nice weekend :)
The text was updated successfully, but these errors were encountered: