Handling error in apollo graphql returns invalid doctype even when content type is json

Handling error in apollo graphql returns invalid doctype even when content type is json


-1

I have tried sending 404 status using json-server and it works with postman as seen below.

Handling error in apollo graphql returns invalid doctype even when content type is json

But when I’m doing it inside apollo sandbox, it’s giving me this invalid doctype. Not sure why json-server is sending out html instead of json content type because I’ve already set it

Handling error in apollo graphql returns invalid doctype even when content type is json

Here is the json-server

Handling error in apollo graphql returns invalid doctype even when content type is json

Here’s my datasource

Handling error in apollo graphql returns invalid doctype even when content type is json

I tried casting the error to ApolloError but to no avail

throw new ApolloError('InputValidationError', 'INVALID_INPUT', { error });

The server

Handling error in apollo graphql returns invalid doctype even when content type is json

What am I missing?

1 Answer
1


-1

Forgot to add error formatting in the server. Refer to https://www.apollographql.com/docs/apollo-server/v2/data/errors/#masking-and-logging-errors

formatError: (err) => { return err; },

0



Leave a Reply

Your email address will not be published. Required fields are marked *