标签: graphql-shield

Graphql-Shield 劫持错误

在解析器中,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!",
Run Code Online (Sandbox Code Playgroud)

这是 Apollo 服务器设置

    const schema = buildSubgraphSchema([
      { typeDefs: await typeDefs(), resolvers },
    ]);
    const apolloServer = new ApolloServer({
      schema: applyMiddleware(schema, permissions),
      context: async ({ req, res }) => new AuthenticatedContext(req, res)
    });
Run Code Online (Sandbox Code Playgroud)

如何返回实际发生的错误?

apollo graphql apollo-server graphql-shield

1
推荐指数
1
解决办法
409
查看次数

标签 统计

apollo ×1

apollo-server ×1

graphql ×1

graphql-shield ×1