khaosdoctor / gotql

GraphQL query utility for serverside apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Adding custom gotInstance results in error

pilar1347 opened this issue · comments

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

Checking it today

I ran some tests and managed to simulate the problem locally.
The failure is occurring due to the version of the package got.
In version 9 the request works normally, but if we upgrade to version 11, it returns the error reported by @pilar1347 .
@khaosdoctor if you want, I can open a pull request with the minimum changes so that gotql works in version 11 (got), but we will have some changes in the runner.ts file, modifications in the typescript types and test correction

@tiago154

I think it's past time we update got's version in this package... It should work with the latest one, if you could please start the changes. I will do the same over here and we merge them.

I, personally, think there won't be a lot of changes to the typings in general, however if they do change we can always use got's exported definitions

@khaosdoctor The pull request #49 is open. Look carefully at the changes I made and it is very likely that we still have to change something. If you need anything, I'm at your disposal.

I'll take a look right now! Thanks a lot for the help!

Reopening to add tests for this

@pilar1347 can you please test again and see if this error is still occurring?

PS: Make sure to update to v2.0.1

Updated to 2.0.1 and verified that it is working without error. Thank you for fixing this so quickly!

Awesome! marking it as #fixed!

Thanks @tiago154 for the incredible help on solving this!

Awesome! marking it as #fixed!

Thanks @tiago154 for the incredible help on solving this!

I'm happy to contribute =]