[GH-ISSUE #72] Allow naming mutations #44

Closed
opened 2026-03-03 00:02:56 +03:00 by kerem · 2 comments
Owner

Originally created by @seantalbot-jisc on GitHub (Jul 27, 2022).
Original GitHub issue: https://github.com/atulmy/gql-query-builder/issues/72

The gql.query function takes an optional config object in which I can pass an operationName to name my query. This makes testing queries against a mock GQL server using MSW very easy as I can configure it to respond to incoming queries by the operationName https://mswjs.io/docs/getting-started/mocks/graphql-api#request-handler

The gql.mutation function doesn't take this config object so I can't easily name mutations. This makes testing them with MSW much harder as I have to separately parse the GQL into an AST and locate the name of the underlying mutation that is called.

Could you add this config object to gql-query-builder?

Originally created by @seantalbot-jisc on GitHub (Jul 27, 2022). Original GitHub issue: https://github.com/atulmy/gql-query-builder/issues/72 The `gql.query` function takes an optional config object in which I can pass an `operationName` to name my query. This makes testing queries against a mock GQL server using MSW very easy as I can configure it to respond to incoming queries by the `operationName` https://mswjs.io/docs/getting-started/mocks/graphql-api#request-handler The `gql.mutation` function doesn't take this config object so I can't easily name mutations. This makes testing them with MSW much harder as I have to separately parse the GQL into an AST and locate the name of the underlying mutation that is called. Could you add this config object to gql-query-builder?
kerem 2026-03-03 00:02:56 +03:00
Author
Owner

@themagickoala commented on GitHub (Nov 30, 2022):

@atulmy I've submitted a PR for this issue. We are hoping to use this package but the operationName for mutations is a hard requirement as we're using MSW too.

<!-- gh-comment-id:1331878609 --> @themagickoala commented on GitHub (Nov 30, 2022): @atulmy I've submitted a PR for this issue. We are hoping to use this package but the operationName for mutations is a hard requirement as we're using MSW too.
Author
Owner

@atulmy commented on GitHub (Nov 30, 2022):

@themagickoala thanks for your contribution, the package has been published:
https://www.npmjs.com/package/gql-query-builder/v/3.8.0

<!-- gh-comment-id:1331901523 --> @atulmy commented on GitHub (Nov 30, 2022): @themagickoala thanks for your contribution, the package has been published: https://www.npmjs.com/package/gql-query-builder/v/3.8.0
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/gql-query-builder#44
No description provided.