在解析器中,throw new createError.BadRequest("bad input")
错误被劫持Graphql-shield
并显示为
{
"errors": [
{
"message": "Not Authorised!",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"myMutation"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Not Authorised!",
这是 Apollo 服务器设置
const schema = buildSubgraphSchema([
{ typeDefs: await typeDefs(), resolvers },
]);
const apolloServer = new ApolloServer({
schema: applyMiddleware(schema, permissions),
context: async ({ req, res }) => new AuthenticatedContext(req, res)
});
如何返回发生的实际错误?