I am using react and apollo
I made a query in a file that looks like
query1.graphql
query User($pk: Int!) {
user(pk: $pk) {
id
email
name
userType
...
}
}
Now, in another place in the code I would like to request only one field.
query2.graphql
query User($pk: Int!) {
user(pk: $pk) {
id
}
}
but this during generation will trigger an error that the query is already defined, but I don't want to have all the parameters
Is there a way to do so ? Or I just have to use the big query and keep what I want ?
It's unclear what you're referring to by "generation" or what exact error you're seeing. However, assuming you're using GraphQL Code Generation, each operation must have a unique name, so you cannot have two operations with the same name (User
). Change one of the operation names to something else.