Open benjie opened 4 years ago
Yes please! I strongly support this disambiguation. Shopify has felt this pain at several points internally, both in explaining GraphQL to devs and in our actual code - you don't want to know how many distinct class Query
s we have 😬 .
(edit: secondary 👍 to request
, that's one in particular we've hit since historically we talked about "querying" our REST API).
This has been incredibly painful for me as well -- the ambiguity of this term has been particularly challenging with security and authorization, query registration and persistence, and similar cross-cutting and infrastructure concerns.
I already try to point people to the graphql spec to make these conversations more precise, so I'm very supportive of any efforts to disambiguate the word "query" in the spec itself.
Accepted to progress by the GraphQL WG. I'll be the champion for this and will be outlining steps forward over the coming weeks.
At Apollo we were recently discussing where to use "query" in docs and UI, and where to avoid it in favor of another word to avoid ambiguity. Some of the opinions behind our current strategy are:
Thanks for your input @StephenBarlow; this is in line with my thoughts. "Querying your graph" definitely sounds like the query (as opposed to mutation) side of things to me, and I think that's fine depending on context.
Have filed a PR for this via #777 and am adding it to the next GraphQL WG: https://github.com/graphql/graphql-wg/pull/497
(Sorry about the delay; it's been hectic. Took a day without internet to finally get around to this!)
We have a general issue in the GraphQL ecosystem that the term "query" is overloaded - sometimes it refers to the query operation type or a query operation, sometimes it refers to a GraphQL request or a GraphQL document containing operations, sometimes it refers to the contents of selection sets (as in "query reuse"), and sometimes it is used as a verb to refer to the generic act of querying a server for information.
This is exacerbated by us using the term "query" in the communication with the server via
{query, variables, operationName}
. Arguablyquery
should bedocument
here since it may contain multiple operations, and those operations might be of different operation types (query, mutation, subscription). I believe this ship may have already sailed, however, and may not be worth the churn of changing this particular usage now.The spec tends to be fairly disciplined in referencing query currently; it uses the following phrases:
query
in a query operation)The term
query
orGraphQL query
, when used as a noun outside the above phrases, typically refers to an operation (within a document). In this use it generally applies to all operation types:but sometimes it only applies to the query operation type:
Sometimes, rather than referring to an operation within a document,
query
refers to the operation type itself:I'd like to attempt to reduce the ambiguity of the term
query
by carefully replacing it with more appropriate terms (typicallyoperation
,document
and mayberequest
) throughout the GraphQL spec. However, as this is likely to take quite some time to do I wanted to seek approval before investing the time in a pull request. Further, it may make sense to do this in stages.