Giter VIP home page Giter VIP logo

Comments (20)

luchillo17 avatar luchillo17 commented on March 29, 2024 7

Using formatError as well, is there a way to pass the same error handler when using in testing? (in tests you most of the time query directly using the graphql object to execute the query with the schema.

import {
  graphql,
} from 'graphql';
...
let resp = (await graphql(Schema, query, {}, context));

from graphql-js.

tristanz avatar tristanz commented on March 29, 2024 3

This seems to be fixed here: https://github.com/graphql/express-graphql/pull/45/files

  graphiql: true,
  formatError: (error) => ({
    message: error.message,
    details: config.isProduction ? null : error.stack
  })

from graphql-js.

IvanGoncharov avatar IvanGoncharov commented on March 29, 2024 2

@bkoltai @alfaproject You can access original errors and their stack traces, like that:

const result = await execute(/* ... */);
if (result.errors) {
  result.errors.forEach(err => console.log(err.originalError));
  // ...
}

from graphql-js.

trobertsonsf avatar trobertsonsf commented on March 29, 2024 1

👍 Really hard to debug ATM.

from graphql-js.

JanPeter avatar JanPeter commented on March 29, 2024 1

I have currently the same problem. I'm not quite sure how to test my custom error messages. Or is it better to test the whole express-graphql endpoint for the error messages?

from graphql-js.

madjam002 avatar madjam002 commented on March 29, 2024

Yeah this would be useful. Maybe a dev flag which could be passed to the graphql function during dev which exposes stack traces as well as error messages?

from graphql-js.

leebyron avatar leebyron commented on March 29, 2024

Yeah, I feel this pain as well. I have a broader error handling refactor I need to do that should help this be less painful

from graphql-js.

johanatan avatar johanatan commented on March 29, 2024

+1 on this.

from graphql-js.

payneio avatar payneio commented on March 29, 2024

This is killing me.

from graphql-js.

johanatan avatar johanatan commented on March 29, 2024

in error/formatError.js I've added the line:

    stack: error.stack,

to the JSON returned and it has helped tremendously.

from graphql-js.

rexxars avatar rexxars commented on March 29, 2024

+1 for this

Thanks for the tip, @johanatan! Lifesaver!

from graphql-js.

jsplink avatar jsplink commented on March 29, 2024

+1 good call johanastan

from graphql-js.

mrjackdavis avatar mrjackdavis commented on March 29, 2024

Now that #118 has been merged; what's the next step forward here? graphql/express-graphql#4 is closed but to my knowledge this issue is not resolved. How can we help?

from graphql-js.

brokentone avatar brokentone commented on March 29, 2024

+1

from graphql-js.

jeromecovington avatar jeromecovington commented on March 29, 2024

Has anybody patched this with #28 (comment) via @johanatan?

from graphql-js.

vinerz avatar vinerz commented on March 29, 2024

+1, also, @johanatan, thanks a lot. I've already made a statue from you

from graphql-js.

zuhair-naqvi avatar zuhair-naqvi commented on March 29, 2024

+1

from graphql-js.

leebyron avatar leebyron commented on March 29, 2024

Closing this since graphql-js no longer formats Errors anymore (the errors field on the output is a list of the original Error instances now).

Formatting is still recommended when using over a web endpoint, and express-graphql does the simple thing by default and allows for customization.

from graphql-js.

bkoltai avatar bkoltai commented on March 29, 2024

Agreed, how do we get a stack trace for the errors reported from using the graphql function directly, which I'm also doing in tests and get errors from my code with just the message and no trace.

from graphql-js.

alfaproject avatar alfaproject commented on March 29, 2024

Just stumbled upon this issue and not quite sure why is it closed. I only get the error title when invoking with graphql or execute...

from graphql-js.

Related Issues (20)

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.