I'm migrating from ApolloServer to GraphQL Yoga server, and in the plugins of ApolloServer, they have the didEncounterError
method which gives you access to the context, and I couldn't find something similar in the documentation of Yoga, does anyone have an idea how can I access the context when an error occurs?
This is what I had on ApolloServer
const apolloServer = new ApolloServer({
...,
plugins: [
{
requestDidStart() {
return {
didEncounterErrors(context) {
context.errors.forEach(error => {
console.log(context.operationName);
console.log(error);
}
});
};
},
},
],
});
Thanks for your help!
You can use the
useLogger
plugin fromgraphql-yoga
like this: