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.

GraphQL Stack Traces are (Needlessly) Unhelpful;

See original GitHub issue

Here is a stack trace I recently got:

 Error: Cannot return null for non-nullable field User.id.
    at completeValue (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:560:13)
    at completeValueCatchingError (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:495:19)
    at resolveField (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:435:10)
    at executeFields (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:275:18)
    at collectAndExecuteSubfields (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:713:10)
    at completeObjectValue (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:703:10)
    at completeValue (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:591:12)
    at completeValueCatchingError (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:495:19)
    at resolveField (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:435:10)
    at executeFields (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:275:18)
    at collectAndExecuteSubfields (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:713:10)
    at completeObjectValue (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:703:10)
    at completeValue (/home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:591:12)
    at /home/me/projects/my-project/server/node_modules/graphql/execution/execute.js:492:16

The problem is, it’s entirely made up of lines from graphql, which means it’s entirely worthless for helping me understand where the error occurred (ie. the entire thing stack traces are supposed to do). All I know is that it involved a resolver which somehow involved a User ID.

I don’t mean to sound ungrateful for awesome free software (that is the best way to build an API today) … and I very much am appreciative of all the hard work that has gone into this project … but would it kill you to at least include the query and variables used in the stack trace?

At the moment it really feels like the library is saying “Oh you messed up? Well, too bad: you’re on your own now chump! That’s you what you get for making a mistake.” 😉 But surely you want to help users understand errors, no? And surely GraphQL has the query/variables available to include in the error, since it receives both long before the error occurs?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
Markus-ipsecommented, Jun 18, 2021

This issue is still very much valid, the error messages are really not helpful at all. See the below one for instance - based on it I have no idea where to look or what to even look for 😦 image

Is there any work ongoing that is trying to remedy this?

4reactions
IvanGoncharovcommented, Oct 9, 2019

@machineghost Thanks for your report 👍 It’s definitely something we should try to address since I fully agree that current error gives you an absolute minimum of info. By default JS environments output description + call trace and we can’t include a query or query variables into description since they can be huge and description is sent to the API client. However, I definitely agree that we should try to find solutions to provide more details in printed error messages.

At the moment we are in feature freeze due to the upcoming TS conversion but after it’s done we will definitely try to address this problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Definitive Guide to Handling GraphQL Errors | by Matt Krick
Don't Intentionally Throw Errors in GraphQL · All errors are sanitized and ready for the viewer before they hit the client · You...
Read more >
Error handling - Apollo GraphQL Docs
The stacktrace error field is useful while developing and debugging your server, but you probably don't want to expose it to clients in...
Read more >
HTTP status code handling in GraphQL APIs - Stack Overflow
Doing so unnecessarily mixes unrelated concepts -- if you want to identify the type of error, you're better off using descriptive codes like ......
Read more >
Using GraphQL to Improve Data Hydration in our Customer ...
Uber Engineering details how GraphQL integrated into our Customer Care ... tickets with aggregated data hydrated across Uber's tech stack.
Read more >
Handling GraphQL errors like a champ with unions and ...
Error handling can be frustrating in GraphQL. ... LogRocket records console logs, JavaScript errors, stacktraces, network requests/responses ...
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