Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer 'operation' to 'query' #48

Open
dukedave opened this issue Aug 2, 2019 · 0 comments

Comments

@dukedave
Copy link

commented Aug 2, 2019

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:

if (queryType === 'query') {

} else if (queryType === 'mutation') {

} else if (queryType === 'subscription') {

⬆️ 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

    module.exports = {
    query,

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.