graphqurl
graphqurl copied to clipboard
Prefer 'operation' to 'query'
Per the docs
The operation type is either query, mutation, or subscription and describes what type of operation you're intending to do.
However many places in the README, and the library itself conflate 'query' with 'operation'. For example:
Under More Examples we see:
const { query } = require('graphqurl');
query(
{
query: `
mutation ($id_insert_input: String!, $column_insert_input: String!) {
And later:
query(
{
query: 'subscription { table { column } }',
Under CLI we see:
gq \
[snip]
--variableFile='./queryVariables.json' \
--queryFile='./query.gql
... but there is nothing to stop './query.gql
containing a mutation
.
In the code itself there is a red flag here:
https://github.com/hasura/graphqurl/blob/dbe963ce82e729002c48038ebb0dfabda34f783c/src/query.js#L75 https://github.com/hasura/graphqurl/blob/dbe963ce82e729002c48038ebb0dfabda34f783c/src/query.js#L83 https://github.com/hasura/graphqurl/blob/dbe963ce82e729002c48038ebb0dfabda34f783c/src/query.js#L91
⬆️ per the doc linked at the start of this issue I propose this should definitely be operationType
.
Would you accept a PR to:
-
Change the README to prefer 'operation' to 'query'.
-
Rename
query.js
tooperation.js
, and: Re-exportoperation
asquery
(to prevent API breaking change) in https://github.com/hasura/graphqurl/blob/dbe963ce82e729002c48038ebb0dfabda34f783c/src/index.js#L4-L5 -
Add
--operationFile
to the CLI as an alias of--queryFile
❓