graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

Error when same variable name but different type in the same file

Open Sytten opened this issue 3 years ago • 1 comments

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

Sytten avatar Jan 12 '22 01:01 Sytten

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".

Sytten avatar Mar 30 '22 15:03 Sytten