John Glabb
John Glabb

Reputation: 1621

How to add custom HTTP response to graphql createHandler method?

GraphQl returns 200 even in case of error but with errors object in response. I want to set it to 400. Assume I need to integrate it into createHandler?

import { createHandler } from "graphql-http/lib/use/express";
import mySchema from "./.mySchema";

const StringArrayScalar = new GraphQLScalarType({......

var root = {
    query1({ id }) {
        return xxx
    },
    query2({ id }) {
        return xxx
    },
};

const handler = createHandler({
    schema: mySchema,
    rootValue: root,
    pretty: true,
    graphiql: true,
    resolver: {
        StringArray: StringArrayScalar,
    }
});

export default handler;

Upvotes: 0

Views: 127

Answers (0)

Related Questions