Skip to content

GraphQL Error Swallowed Natively but works in Express-graphqlΒ #1326

@alifaff

Description

@alifaff

Using Graphql 0.13.2

Executing graphql natively as follows through AWS Lambda:

index.js - calls

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

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions