FG
๐Ÿ’ป Software๐Ÿ”Œ APIs & SDKs

GraphQL Error Swallowed Natively but works in Express-graphql

Freshalmost 8 years ago
Mar 14, 20260 views
Confidence Score84%
84%

Problem

Using Graphql 0.13.2 Executing graphql natively as follows through AWS Lambda: index.js - calls [code block] If the executing code throws an error, it usually returns message as string with [object, Object]. I suspect it wraps to GraphQLError. If I wrap the above error object using GraphQLError then I do not get anything back and my response.errors is an empty object {}. The only way I am able to get back data properly is to return an Error as a string or a GraphQLError as a string, I am unable to push back an object. Oddly enough if I run GraphQL with express and add the formatError with an error handler then that works, however using it natively it does not. It seems that I am missing something simple to get GraphQL to return the object instead of only working with strings. Any ideas?

Error Output

error object using GraphQLError then I do not get anything back and my response.errors is an empty object {}.  The only way I am able to get back data properly is to return an Error as a string or a GraphQL

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Moderate Confidence Fix
84% confidence100% success rate1 verificationLast verified Mar 14, 2026

Solution: GraphQL Error Swallowed Natively but works in Express-graphql

Low Risk

> return graphql(schema, query, null, {params}, variables) @alifaff You shouldn't wrap `params` into the object. > It seems that I am missing something simple to get GraphQL to return the object instead of only working with strings. Any ideas? Not sure that I fully understand your question. Can you please provide a minimal example of the actual and expected output. Also, do you use `JSON.string

84

Trust Score

1 verification

100% success
  1. 1

    > return graphql(schema, query, null, {params}, variables)

    > return graphql(schema, query, null, {params}, variables)

  2. 2

    @alifaff You shouldn't wrap `params` into the object.

    @alifaff You shouldn't wrap `params` into the object.

  3. 3

    > It seems that I am missing something simple to get GraphQL to return the objec

    > It seems that I am missing something simple to get GraphQL to return the object instead of only working with strings. Any ideas?

  4. 4

    Not sure that I fully understand your question. Can you please provide a minimal

    Also, do you use `JSON.stringify` to generate response string?

Validation

Resolved in graphql/graphql-js GitHub issue #1326. Community reactions: 0 upvotes.

Verification Summary

Worked: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

graphqlapischema