graphql-client
graphql-client copied to clipboard
Error when same variable name but different type in the same file
In a graphql file, I have two mutations with $input as a variable, like:
mutation CreateProject($input: CreateProjectInput!) {
createProject(input: $input) {
...
}
}
mutation CreateScope($input: CreateScopeInput!) {
createScope(input: $input) {
...
}
}
When trying to execute the mutation CreateProject, I get the following error:
Response { data: None, errors: Some([Error { message: "Invalid value for argument \"input\", field \"allowlist\" of type \"CreateScopeInput\" is required but not provided", locations: Some([Location { line: 62, column: 15 }]), path: None, extensions: None }]) }
So basically you can't have two variable with the same name but different type in the same graphql file
I did some digging and I dont think this is a simple fix. This is due to the fact that graphql-client includes the whole query file in each request. I think this should probably closed as "worked as expected".