Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
connection.formatResponse = (value: ExecutionResult) => {
return {
...value,
errors:
value.errors &&
formatApolloErrors([...value.errors], {
debug: apolloServer.requestOptions.debug,
formatter: apolloServer.requestOptions.formatError,
}),
};
};
let context: Context = apolloConfig.context
.catch(error => {
if (error.status && error.expose) res.status(error.status);
next(
formatApolloErrors([error], {
formatter: server.requestOptions.formatError,
debug: server.requestOptions.debug,
}),
);
});
} else {
}),
};
};
let context: Context = apolloConfig.context
? apolloConfig.context
: { connection };
try {
context =
typeof apolloConfig.context === "function"
? await apolloConfig.context({
connection,
payload: message.payload,
})
: context;
} catch (e) {
throw formatApolloErrors([e], {
debug: apolloServer.requestOptions.debug,
formatter: apolloServer.requestOptions.formatError,
})[0];
}
return { ...connection, context };
},
schema,