Originally posted by ShourovRoy November 2, 2022
Apollo Graphql has a function to modify status code on error that can be overridden which plays an important role for implementing refresh token. Is there any way to do that here?
Apollo server allows errors to change the status code, maybe we can do the same:
import { GraphQLError } from 'graphql';
const resolvers = {
Query: {
someField() {
throw new GraphQLError('the error message', {
extensions: {
code: 'SOMETHING_BAD_HAPPENED',
http: {
status: 404,
headers: new Map([
['some-header', 'it was bad'],
['another-header', 'seriously'],
]),
},
},
});
},
},
};
https://www.apollographql.com/docs/apollo-server/data/errors/#setting-http-status-code-and-headers
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too