question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Adding custom gotInstance results in error

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
pilar1347commented, Jul 31, 2020

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

2reactions
tiago154commented, Jul 29, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom errors thrown in afterResponse are suppressed #1352
Describe the bug If my afterResponse hook throws a custom error, I'm not expecting it to be rewritten into a Got Request Error...
Read more >
Custom errors, extending Error - The Modern JavaScript Tutorial
When we develop something, we often need our own error classes to reflect specific things that may go wrong in our tasks.
Read more >
Best Practices for Node.js Error-handling - Toptal
Developers working with Node.js sometimes find themselves writing not-so-clean code while handling all sorts of errors. This article will introduce you to ...
Read more >
A Comprehensive Guide To Error Handling In Node.js
Custom error classes that extend the Error object will retain the basic error properties, such as message , name , and stack ,...
Read more >
What's a good way to extend Error in JavaScript?
Test cases I used can be found here: JavaScript self-made Error object ... (If you want to add custom methods to your subclass,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found