Temporarely fix apollo error bug.

This commit is contained in:
Valentin Boettcher 2019-03-06 00:20:29 +01:00
parent b6da989deb
commit e6d6049184
2 changed files with 12 additions and 4 deletions

View file

@ -77,8 +77,8 @@ export const getErrors = error => {
// if this is one or more GraphQL errors, extract and convert them
if (error.graphQLErrors && error.graphQLErrors.length > 0) {
// get first graphQL error (see https://github.com/thebigredgeek/apollo-errors/issues/12)
const graphQLError = error.graphQLErrors[0];
const data = get(graphQLError, 'extensions.exception.data')
const graphQLError = error.graphQLErrors[0].extensions.exception.errors[0];
const data = get(graphQLError, 'extensions.data')
if (data && !isEmpty(data)) {
if (data.errors) {
// 2. there are multiple errors on the data.errors object

View file

@ -1,4 +1,4 @@
import { ApolloError } from 'apollo-server';
import { GraphQLError } from 'graphql';
/*
@ -11,5 +11,13 @@ An error should have:
*/
export const throwError = error => {
const { id, } = error;
throw new ApolloError(id, 'VALIDATION_ERROR', error);
throw new GraphQLError(
id,
null,
null,
null,
null,
null,
error
);
};