GithubHelp home page GithubHelp logo

khaosdoctor / gotql Goto Github PK

View Code? Open in Web Editor NEW
405.0 7.0 20.0 1.8 MB

GraphQL query utility for serverside apps

License: MIT License

TypeScript 96.55% Dockerfile 2.89% JavaScript 0.56%
graphql-query graphql-endpoint graphql got http http-client hacktoberfest nodejs javascript

gotql's Introduction


GotQL


Write GraphQL queries as objects instead of strings

This is a better implementation of the GraphQL query API via NodeJS, created as a wrapper of Got. It works like a transpiler, with a built in HTTPRequest Client (Got), allowing you to write your GraphQL queries as Javascript Objects instead of strings.

Built because manipulating strings is a real pain.

Table of Contents

Install

$ npm install gotql

Or

$ yarn install gotql

Basic Usage

const gotQl = require('gotql')

const query = {
  operation: {
    name: 'users',
    fields: ['name', 'age', 'id']
  }
}

const options = {
  headers: {
    "Authorization": "Bearer <token>"
  },
  debug: false,
  useHttp2: false
}

gotQL.query('mygraphqlendpoint.com.br/api', query, options)
  .then(response => console.log(response.data))
  .catch(console.error)

What is it?

GotQL is a better interface for GraphQL queries. It provides a way for developers to run queries using JSON instead of strings. Which is a way more usable data format than the string itself.

See more on: https://hasura.io/blog/fluent-graphql-clients-how-to-write-queries-like-a-boss/

Motivation

Manipulating strings is very smelly, even on dynamically typed languages. So, in order to avoid things such as this:

Which can be translated to something waay more readable in a JSON format like this:

const mutation = {
  operation: {
    name: 'addLog',
    args: {
      logType: literal`status_change`, // Enum Value
      fromState: variables.fromState,
      toState: variables.toState,
      idUser: variables.idUser,
      idCampaign: variables.idCampaign,
      owner: {
        ownerType: variables.ownerType,
        username: variables.username,
        picture: variables.picture,
        name: variables.name,
        id: variables.id
      }
    },
    fields: [ 'uuid' ]
  }
}

This is why GotQL was created.

API

gotQl.query(graphQLEndpoint, query, [options])
  • Description: Performs a graphQL query

GraphQLEndpoint

  • Type: string
  • Description: The GraphQL endpoint to query on

query

options

See option object for more information.


gotQl.mutation(graphQLEndpoint, query, [options])
  • Description: Performs a graphQL mutation

GraphQLEndpoint

  • Type: string
  • Description: The GraphQL endpoint to query on

query

options

See option object for more information.


gotQl.parser(query, type)
  • Description: Parses a JSON-Like query and returns the query's string

query

type

  • Type: string
  • Description: Must be either 'query' or 'mutation'

Option Object

Both gotql.query and gotql.mutation accept an optional user option object with the following API:

  • Type: object
  • Description: The option object with the following properties.
    • errorStatusCode: Default HTTP status code to be returned on error
      • Type: number
    • headers: Additional headers to be sent
      • Type: object, in the form of [headerName: string]: headerValue: string
    • gotInstance: Customized Got instance to be used when calling the endpoint
      • Type: got. Internally this will be called as got.post(prependHttp(endPoint), gotPayload)
    • useHttp2: Boolean defining if the call should be made using HTTP2, defaults to false (see release 11 of got)
      • Type: boolean

Note: GotQL uses debug internally as default debugger, so you can set debug levels by setting the DEBUG environment variable. These are the current levels:

  • gotql:info
  • gotql:info:parser
  • gotql:info:runner
  • gotql:errors

Returns

All methods return a string like this:

const response = 'query { test { name args } }'

The JSON query format

The JSON format gotQL uses is a simple and intuitive description based on the anatomy of a GraphQL query blog post.

This is a generic model of a JSONLike query:

const query = {
  name?: string,
  operation: {
    name: string,
    alias?: string,
    args?: { [argName: string]: any } | {
      [argName: string]: {
        value: string,
        escape: boolean
      }
    },
    fields: (string | {
      [fieldName: string]: [{
        args?: { [argName: string]: any } | {
          [argName: string]: {
            value: string,
            escape: boolean
          }
        },
        fields?: (string | { [fieldName: string]: [any] })[]
      }]
    })[]
  },
  variables?: {
    [varName: string]: {
      type: string,
      value: string
    }
  }
}

Description

  • Query:
    • Type: object
    • Description: The full query object
    • Properties:
      • name: [optional]: Query name
        • Type: string
      • variables: [optional] Query variable declaration
        • Type: object with signature like [varName: string]: { type: string, value: string }
        • Properties:
          • varName: Variable name
            • Type: string
          • type: Variable type. Can be a GraphQL definition of type (i.e: string!)
            • Type: string
          • value: Variable value
            • Type: any
      • operation: The query operation (action that will be executed)
        • Type: object
        • Properties:
          • name: The operation name
            • Type: string
          • alias: [optional] An alias to give the operation
            • Type: string
          • args: [optional] The operation args
            • Type: [argName: string]: any or a detailed arg object
              • Simple args: An object where the key is the argument name and its value. Accepts variables in the format of argName: '$value'
                • Example: args { name: 'myName' }
              • Detailed args: A tagged template. This will give more control over escaping (mostly to use enums). Argument name should be the key
                • Type: tagged template
                • Examples: args: { status: literal`an_enum` } should output operation (status: an_enum)...
          • fields: The field list to get back from the operation
            • Type: An array of object (to use nested fields) or string, or both.
            • Properties (for nested fields):
              • Type: object where the field name is the key
              • fields: Recursive definition, accepts another array just like the fields above.
              • args: [optional] The field args
                • Type: [argName: string]: any or a detailed arg object
                  • Simple args: An object where the key is the argument name and its value. Accepts variables in the format of argName: '$value'
                    • Example: args { name: 'myName' }
                  • Detailed args: A tagged template. This will give more control over escaping (mostly to use enums). Argument name should be the key
                    • Type: tagged template
                    • Examples: args: { status: literal`an_enum` } should output operation (status: an_enum)...

Examples

Simple query

const query = {
  operation: {
    name: 'users',
    fields: ['name', 'age']
  }
}

Outputs:

query { users { name age } }

Named query

const query = {
  name: 'myQuery',
  operation: {
    name: 'users',
    fields: ['name', 'age']
  }
}

Outputs:

query myQuery { users { name age } }

Query with simple args

const query = {
  operation: {
    name: 'users',
    args: {
      name: 'Joe'
    },
    fields: ['name', 'age']
  }
}

Outputs:

query { users(name: "Joe") { name age } }

Query with variables

const query = {
  variables: {
    name: {
      type: 'string!',
      value: 'Joe'
    }
  },
  operation: {
    name: 'users',
    args: {
      name: '$name'
    },
    fields: ['name', 'age']
  }
}

Outputs:

query ($name: string!) { users(name: $name) { name age } }

Variables are sent on a separate object to graphQL.

{
  "variables": { "name": "Joe" }
}

Nested fields

const query = {
  operation: {
    name: 'users',
    fields: [
      'name',
      'age',
      {
        friends: {
          fields: ['name', 'age']
        }
      }
    ]
  }
}

Outputs:

query { users { name age friends { name age } } }

Recursive fields can go forever.

Enum and literal args

Enum or literal values should not be escaped, to do that, GotQL has a helper called literal which can be used to tell the query that value will not be escaped:

const { literal } = require('gotql')

const query = {
  operation: {
    name: 'users',
    args: {
      type: literal`internal`
    },
    fields: ['name', 'age']
  }
}

The code above outputs:

query { users(type: internal) { name age } }

The literal helper is just a shorthand to the old-style {value: string, escape: boolean} object like below:

const query = {
  operation: {
    name: 'users',
    args: {
      type: {
        value: 'internal',
        escape: false
      }
    },
    fields: ['name', 'age']
  }
}

If literal is omitted, or if escape is set to true, the output would be:

query { users(type: "internal") { name age } }

Note: Variables such as described here will not be recognized. If the arg object is not an [argName]: value, variables will not pass through the definition check (GotQL warns if a variable is not declared but used on operation).

Contributing to this project

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Hey! If you want to contribute, please read the contributing guidelines ๐Ÿ˜„

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

gotql's People

Contributors

dependabot[bot] avatar khaosdoctor avatar monkeywithacupcake avatar pigulla avatar revadike avatar roziscoding avatar screendriver avatar tiago154 avatar vaidkaran avatar wm4tos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gotql's Issues

Support Int type arguments

Is your feature request related to a problem? Please describe.
When I pass in a number in a query using this library, I get an error response from the server API that it was passed a string instead of an int.

Describe the solution you'd like
Pass numbers through the checkArgs function without converting them to string.

Give some examples of implementations
PR coming.

Chokes on Complex Nested Fields with Arguments

query ($customerCode: String!, $dataRepositoryCode: String!, $dataCollectionCode: String!, $dataRecordIDs: [String!]!, $limit: Int) {
  customer(customerCode: $customerCode) {
    customerCode
    dataRepository(dataRepositoryCode: $dataRepositoryCode) {
      customerCode
      dataRepositoryCode
      metadata
      dataCollection(dataCollectionCode: $dataCollectionCode) {
        dataRecords(dataRecordIDs: $dataRecordIDs, limit: $limit) {
          entities {
            values
            relatedDataRecords
          }
        }
      }
    }
  }
}

[FEATURE] Insert multiple values from mutation

Right now, it doesn't seem possible to insert multiple values from one mutation.

Example graphQL query:

mutation insertMultipleThings($things: [things_insert_input!]!) {
	insert_things(objects: $things) {
		affected_rows
	}
}

The equivalent I tried with gotql was:

const things = [{name: 'thing1'}, {name: 'thing2'}]
const mutation = {
  operation: {
    name: 'insert_things',
    args: {
      objects: things,
    },
    fields: ['affected_rows'],
  },
}

gotQl.mutation(graphQLEndpoint, mutation)

I also attempted the less intuitive:

const things = [{name: 'thing1'}, {name: 'thing2'}]
const mutation = {
  operation: {
    name: 'insert_things',
    args: {
      objects: {
	value: things,
	escape: false,
      },
    },
    fields: ['affected_rows'],
  },
}

gotQl.mutation(graphQLEndpoint, mutation)

In the end I had to go with the horrifying:

const things = JSON.stringify([{name: 'thing1'}, {name: 'thing2'}]).split('"name"').join('name')
const mutation = {
  operation: {
    name: 'insert_things',
    args: {
      objects: {
	value: things,
	escape: false,
      },
    },
    fields: ['affected_rows'],
  },
}

gotQl.mutation(graphQLEndpoint, mutation)

Given that operation.args.objects has the plural already in the name and it's a valid query to pass an array, I'd expect objects to be allowed being passed an array (my first gotql attempt).

[FEATURE] Add inline fragments support

I have seen that there is a closed issue regarding adding graphql fragments support for v1.7.0 but I haven't found it in release notes or source code.
Could you implement such a feature for gotql or give an example of how to use it if I am wrong and gotql v2.* supports fragments?
We are using gotql for more than 6 months and it's already deeply implemented in our code to change it to something else.

Use GOT cache mechanism to cache GRAPHQL responses

Is that possible to cache post requests on a GRAPHQL endpoint?

Could help me with some ideas to accomplish this?

I already tried to use the got cache mechanism with redis but by now, without success.

Thank you very much!

Decouple Parser

Decouple the parse function from the parse and export it to the main module, allowing the user to use only the parser and not the client

Is this an active project?

My team wants to POC this library for our graph backend tests, but the last commits were from over a year ago. Is this project still alive, or has it been deprecated?

Arg parsing error (Cannot read property 'indexOf' of undefined)

Describe the bug
Null arg values are not supported (Cannot read property 'indexOf' of undefined)

To Reproduce

  return gotQl.mutation('https://example.com', {
    operation: {
      name: 'update_users',
      args: {
        where: {id: {_eq: userId}},
        _set: {name: null},
      },
      fields: ['affected_rows'],
    },
  })

Current behavior

Runner error: Error when executing query: Parse error: Failed to parse operation "update_users" => Cannot read property 'indexOf' of undefined

Expected behavior
null values should be supported.

Add Integration tests

Add integration tests to make sure queries and mutations are indeed working properly.

  • Create a small GraphQL server
  • Use JSON as local DB
  • Test mutations
  • Test Queries
  • Add it all to Travis

[FEATURE] Allow empty fields for mutations

Is your feature request related to a problem? Please describe.
I have mutations which do not return anything (although I know it's against best practices) and I couldn't use gotql for these mutations as the resulting query string is syntactically wrong and causing Bad Request

gotql:info:parser Parsed query: mutation ($input: TransferInput!) { airdropPoints(args: $input) {  } } +0ms
(node:20166) UnhandledPromiseRejectionWarning: Error: Runner error: Error when executing query: Response code 400 (Bad Request)

Describe the solution you'd like
Empty or nulled fields should not generate something like this:

mutation ($input: TransferInput!) { airdropPoints(args: $input) {  }  }

image
(mind the red marker on the left side, indicating a syntax error)

but this:

mutation ($input: TransferInput!) { airdropPoints(args: $input)  }

image
(no syntax error)

Describe alternatives you've considered
As an alternative I need to make my mutations return something (which I actually consider and will do)

Additional context
I'm putting this as a feature request, as it is kind of my fault, that I'm not following best practices. Nevertheless, I think it's worth mentioning this situation which causes a syntax error on the query.

Thanks, for this pretty handy library! ๐Ÿ™

[BUG] Empty objects for args and variables are not handled properly

Describe the bug
gotql does not handle empty objects for args and variables properly, the handling should be semantically identical to the values being absent, i.e. undefined. The relevant LoC are in getQueryVars and parseOperation.

Bug in getQueryVars()

To Reproduce

parse({
    name: 'TestQuery',
    operation: {
        name: 'TestOp',
        fields: ['field1', 'field2']
    },
    variables: {}
}, 'query'));

Current behavior
Return value is: query TestQuery ) { TestOp { field1 field2 } }

Expected behavior
Return value should be: query TestQuery { TestOp { field1 field2 } }

Bug in parseOperation()

To Reproduce

parse({
    name: 'TestQuery',
    operation: {
        name: 'TestOp',
        args: {},
        fields: ['field1', 'field2']
    }
}, 'query'));

Current behavior
Return value is: query TestQuery { TestOp() { field1 field2 } }

Expected behavior
Return value should be: query TestQuery { TestOp { field1 field2 } }

[BUG] Adding custom gotInstance results in error

Great package! Really hoping to use on my latest project, but I'm running into an error trying to use a custom got instance:

Describe the bug
Adding a custom gotInstance to the options results in the following error:

Error when executing query: The `body`, `json` and `form` options are mutually exclusive

To Reproduce
Code sandbox reproducing issue: https://codesandbox.io/s/fervent-lake-lfeoe?file=/src/index.js
Relevant code:

  const gotInstance = got.extend({
    timeout: 1000
  });

  const query = {
    variables: {
      code: {
        type: "ID!",
        value: code
      }
    },
    operation: {
      name: "country",
      args: {
        code: "$code"
      },
      fields: ["name", "capital"]
    }
  };

  const options = {
    gotInstance
  };

  const response = await gotQL.query(
      "https://countries.trevorblades.com",
      query,
      options
    );

Current behavior
Adding a got instance results in error

Expected behavior
Got instance should be used without error

Additional context
Code sandbox reproducing issue: https://codesandbox.io/s/fervent-lake-lfeoe?file=/src/index.js

Seems to choke on boolean argument values

Describe the bug
While parsing a query with a boolean argument it fails and I see:

Error: Parse error: Failed to parse operation "WHATEVER" => varName.indexOf is not a function

To Reproduce
Steps to reproduce the behavior:

  1. Create a query with a boolean argument
  2. Try to parse it
  3. Feel sad

Expected behavior
I expected to see my query succeed.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Firefox
  • Version: Latest

Additional context
This is a great module, thanks for creating it.

[BUG] Query is not parsed correctly for where:{ _and :[] }

Am i missing something

gotql.parser(
    {
        operation: {
            name: "Metadata",
            args: {
                where: {
                    _and: [
                        { hash: { _in: ['a','b'] } }
                        ,{pool:{ _eq:32}}
                        ]
                }
            },
            fields: ["key", "value"]
        }
    },
    'query'
)

>>> query { Metadata(where: { _and: ["[object Object]", "[object Object]"] }) { key value } }

[BUG] Issue with args containing $ sign

Describe the bug
Parser fails when args value contains $ sign

To Reproduce

const query = {
  operation: {
    name: 'user',
    args: {
      name: '$Joe'
    },
    fields: ['name', 'age']
  }
}

gotQL.parser(query, "query")

Resulting in
Error: Parse error: Failed to parse operation "user" => Variable "Joe" is defined on operation but it has neither a type or a value

Refactor to Typescript

Typescript would really help by adding type definitions an guidelines to the project.

Enum support

Describe the bug
Hasura's on_conflict argument expect enums to be provided without quotes, however gotql does use quotes for every argument value. This result in an error (see screenshots).

To Reproduce

gotQl.mutation(
  process.env.GRAPHQL_HOST,
  {
    operation: {
      name: 'insert_example',
      args: {
        objects: {id, status, price},
        on_conflict: {constraint: 'example_pkey', update_columns: ['status', 'price']},
      },
      fields: ['affected_rows'],
    }
  },
)

Current behavior
Part of the query:

on_conflict: {constraint: \"example_pkey\", update_columns: [\"status\", \"price\"]}

Expected behavior
Part of the query:

on_conflict: {constraint: example_pkey, update_columns: [status, price]}

Screenshots
image
image
image

[BUG] Parse error: Failed to parse operation

Describe the bug

I try to create a mutation that looks like this:

const mutation = {
  operation: {
    name: 'updateSomething',
    args: {
      id: '1234',
      data: {
        name: 'foo',
        status: 'bar',
      },
    },
    fields: ['test'],
  },
};

and I'm calling it like this

const result = await gotQl.mutation(endpoint, mutation, {
  headers: {
    Authorization: `Bearer ${secret}`,
  },
});

But I get following runtime error:

Error: Runner error: Error when executing query: Parse error: Failed to parse operation "updateSomething" => varName.indexOf is not a function
    at Object.<anonymous> (/Users/myproject/node_modules/gotql/dist/modules/runner.js:122:19)
    at Generator.next (<anonymous>)
    at /Users/myproject/node_modules/gotql/dist/modules/runner.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/myproject/node_modules/gotql/dist/modules/runner.js:4:12)
    at Object.run (/Users/myproject/node_modules/gotql/dist/modules/runner.js:103:12)
    at Object.mutation (/Users/myproject/node_modules/gotql/dist/mutation.js:23:21)
    at update (/Users/myproject/myscript.js:35:32)
    at Object.<anonymous> (/Users/myproject/myscript.js:43:1)
    at Module._compile (internal/modules/cjs/loader.js:776:30)

[BUG] Can't use nested args in mutations with TypeScript

Describe the bug

In your README you mention that you can use nested objects:

const mutation = {
  operation {
    name: 'addLog',
    args: {
      logType: { value: 'status_change', escape: false}, // Enum Value
      fromState: variables.fromState,
      toState: variables.toState,
      idUser: variables.idUser,
      idCampaign: variables.idCampaign,
      owner: {
        ownerType: variables.ownerType,
        username: variables.username,
        picture: variables.picture,
        name: variables.name,
        id: variables.id
      }
    },
    fields: [ 'uuid' ]
  }
}

But when you use TypeScript in your project this is not possible because args is defined as

args?: {
  [name: string]: string | ArgObject;
};

export declare type ArgObject = {
    value: string;
    escape: boolean;
};

That means that that you can't set objects as value (like owner in your example). Only strings or objects with { value: '', escape: true/false } are allowed.

To Reproduce
Steps to reproduce the behavior:

  1. Use TypeScript and try to create a mutation with a nested object.

Current behavior
Does not compile.

Expected behavior
Should compile.

[BUG] Empty TypeScript declaration file

Describe the bug

The package that is deployed to npm does not include anything in index.d.ts. It looks like this:

export {};
//# sourceMappingURL=index.d.ts.map

To Reproduce
Steps to reproduce the behavior:

  1. npm install gotql
  2. Open node_modules/gotql/dist/index.d.ts

Current behavior

This package can't be used in a TypeScript project.

Expected behavior

Types should be deployed within that package.

[BUG] Parse error: Failed to parste array inside of args

Describe the bug
I am trying to build a mutation that looks something like this:

const mutatuion = {
      operation: {
        name: 'createCart',
        args: {
          draft: {
            currency,
            store: {
              typeId: 'store',
              key: tenant,
            },
            itemShippingAddresses: [],
            discountCodes: [],
            lineItems: [],
            customLineItems: [],
            customerId: userId,
            shippingAddress: {
              country: tenant,
            },
            shippingMethod: {
              key: 'defaultShipping',
              typeId: 'shipping-method',
            },
            externalTaxRateForShippingMethod: {
              name: 'noTaxes',
              amount: '$amount',
              includedInPrice: false,
              country: tenant,
            },
            taxMode: `$taxMode`,
            custom: {
              typeKey: 'cart',
              fields: [
                {
                  name: 'pceId',
                  value: pceId,
                },
              ],
            },
          },
        },
        fields: this.cartFields,
      },
      variables: {
        amount: {
          type: 'Float!',
          value: '0',
        },
        taxMode: {
          type: 'TaxMode',
          value: 'External',
        },
      },
    }

Current behavior
As soon as the gotql.parser processes this QueryType, the array is truncated by the property custom.fields. This means that the property "value" disappears in the listed object. The Result is something like that:

mutation ( $amount: Float!, $taxMode: TaxMode ) { createCart(draft: { currency: "EUR", store: { typeId: "store", key: "DE" },itemShippingAddresses: [],discountCodes: [],lineItems: [],customLineItems: [],customerId: "uuidv4",shippingAddress: { country: "DE" },shippingMethod: { key: "defaultShipping", typeId: "shipping-method" },externalTaxRateForShippingMethod: { name: "noTaxes", amount: $amount,includedInPrice: false,country: "DE" },taxMode: $taxMode,custom: { typeKey: "cart", fields: [{ name: "pceId" }] } })

Expected behavior
I simply expect the property value with its corresponding value to still be listed in the object. As an example, this value is now represented by the variable pceId

mutation ( $amount: Float!, $taxMode: TaxMode ) { createCart(draft: { currency: "EUR", store: { typeId: "store", key: "DE" },itemShippingAddresses: [],discountCodes: [],lineItems: [],customLineItems: [],customerId: "uuidv4",shippingAddress: { country: "DE" },shippingMethod: { key: "defaultShipping", typeId: "shipping-method" },externalTaxRateForShippingMethod: { name: "noTaxes", amount: $amount,includedInPrice: false,country: "DE" },taxMode: $taxMode,custom: { typeKey: "cart", fields: [{ name: "pceId", value: pceId }] } })

At this stage, I suspect that this bug is caused by the checkArgs function during the isArray condition within your parser.
Thanks, for this pretty library! ๐Ÿ™

response.statusCode should be a Number

Describe the bug
response.statusCode is a String, but it should be a Number. All the libraries I've used so far use numbers for status codes, including nodejs.
https://nodejs.org/api/http.html#http_response_statuscode

To Reproduce
Make a request with gotql.query() and examinine the statusCode property of the response.

Current behavior
typeof response.statusCode === 'string'

Expected behavior
typeof response.statusCode === 'number'

Arrays in args are treated as objects

Arrays nested inside args are translated as objects

To Reproduce

gotQl.mutation(
  process.env.GRAPHQL_HOST,
  {
    operation: {
      name: 'insert_example',
      args: {
        objects: {id, status, price},
        on_conflict: {constraint: 'example_pkey', update_columns: ['status', 'price']},
      },
      fields: ['affected_rows'],
    }
  },
)

Current behavior
Resulting query contains:

update_columns: { 0: "status", 1: "price" }

Expected behavior
Resulting query contains:

update_columns: ["status", "price"]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.