Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty parenthesis on operations with no arguments #2804

Open
lgberro opened this issue Sep 22, 2023 · 1 comment
Open

Empty parenthesis on operations with no arguments #2804

lgberro opened this issue Sep 22, 2023 · 1 comment

Comments

@lgberro
Copy link

lgberro commented Sep 22, 2023

What happened?

It's generating an empty argument operation. Not sure if this complies with GraphQL standard, but it breaks graphql-code-generator.

What did you expect?

Operation with no arguments shouldn't have empty parenthesis.

Minimal graphql.schema and models to reproduce

# schema 
type Mutation {
  deleteAccount: Boolean
}

# expected operation
mutation deleteAccount {
    deleteAccount
}

# generated operation
mutation deleteAccount() {
    deleteAccount
}

versions

v0.17.38

@taako-502
Copy link
Contributor

taako-502 commented Nov 23, 2023

@lgberro

Hi.

I can't figure out how to reproduce the issue. I tried the following steps, but could not reproduce it. Please provide the exact steps for reproduction.

I defined the following in the schema.graphqls file of gqlgen.

type Mutation {
  deleteAccount: Boolean
}

I created a React.js project and used graphql-code-generator to execute graphql-codegen --config codegen.ts. This generated a gql.ts file, which looks like this.

/**
 * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
 */
export function graphql(source: "\n  mutation DeleteAccount {\n    deleteAccount\n  }\n"): (typeof documents)["\n  mutation DeleteAccount {\n    deleteAccount\n  }\n"];

It doesn't seem to have parentheses.

What is wrong with my reproduction steps? Could you please provide the correct library name, file names, etc.?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants