graphqurl icon indicating copy to clipboard operation
graphqurl copied to clipboard

Prefer 'operation' to 'query'

Open davetapley opened this issue 4 years ago • 0 comments

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:

  1. Change the README to prefer 'operation' to 'query'.

  2. Rename query.js to operation.js, and: Re-export operation as query (to prevent API breaking change) in https://github.com/hasura/graphqurl/blob/dbe963ce82e729002c48038ebb0dfabda34f783c/src/index.js#L4-L5

  3. Add --operationFile to the CLI as an alias of --queryFile

davetapley avatar Aug 02 '19 15:08 davetapley