mirror of
https://github.com/atulmy/gql-query-builder.git
synced 2026-04-25 23:55:55 +03:00
[GH-ISSUE #60] operationName not included as a root key of the query object #129
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/gql-query-builder#129
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @aethr on GitHub (Jun 28, 2021).
Original GitHub issue: https://github.com/atulmy/gql-query-builder/issues/60
We've been using
gql-query-builderto replace hand-written queries in our service layer and so far it's working really well, thanks for creating this library.I noticed recently that the GraphQL spec includes the following recommendation:
We've started work to stub out different gql queries and responses in our cypress test suite, and one of the recommendations is to use an explicit
operationNamein your queries, and then use this part of the request object to determine which response to send:This code looks for the
operationNamein the root of the request body, and it seems this approach works well for a lot of developers, but isn't working for us becausegql-query-builderonly includes theoperationNamein the query itself.For now we're working around this simply like:
However, if
gql-query-builderdid this for us we could use the intended syntax:Do you think this is something the library should support in the default adapter, and if so would you like me to make a pull request?
@atulmy commented on GitHub (Jun 28, 2021):
As per their docs:
Are you looking at sending several named operations and need
operationName?@aethr commented on GitHub (Jun 29, 2021):
Right now we're not attempting to send several named operations in the same document, we're just trying to add a bit of annotation to the queries we're sending to assist with tooling.
From a brief read of the current spec it seems like
operationNameis an optional field that should be fine to send even when there's only one named query.However, it does make me wonder, does
gql-query-builderallow us to specify operationName for each query in the document if an Array of queries is passed, like:Since
operationNameis passed through a finalconfigparameter I think it just gets applied to the first query in the document:Perhaps
operationNameneeds to be a field within each query definition, and then theoperationNameapplied in config might be the one that's added to the root of the document.Apologies if this is wasting your time, I'm pretty new to GraphQL so still learning how all of these features are meant to be used.
@atulmy commented on GitHub (Jun 29, 2021):
I'm out of touch with recent evolution in GraphQL world myself, and would rather ask for help/suggestion on this one.