Strapi#beta.3 中的自定义 GraphQL 架构不起作用

我们刚刚将我们的项目升级到 Strapi 版本 3-beta,我们为user模型定义的 GraphQL 模式/extensions/users-permissions/config/schema.graphql不再工作,就像这个文件被忽略了一样。它曾经在最新的 alpha 版本中工作#alpha.26。


这是架构/extensions/users-permissions/config/schema.graphql:


module.exports = {

  query: `

    userSearch(_q: String!): [UsersPermissionsUser]

  `,

  resolver: {

    Query: {

      userSearch: {

        resolver: {

          plugin: 'users-permissions',

          handler: 'User.search'

        }

      },

    }

  }

};


这是将发送到 GraphQL 端点的查询:


query ($_q: String!) {

    userSearch(_q: $_q) {

        id

        first_name

        last_name

    }

}

这是错误,当我们请求该查询时:


{

    "errors": [

        {

            "message": "Cannot query field \"userSearch\" on type \"Query\". Did you mean \"users\"?",

            "locations": [{ "line": 2, "column": 3 }],

            "extensions": {

                "code": "GRAPHQL_VALIDATION_FAILED",

                "exception": {

                    "stacktrace": [

                        "GraphQLError: Cannot query field \"userSearch\" on type \"Query\". Did you mean \"users\"?",

                        "    at Object.Field (/project/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:64:31)",

                        "    at Object.enter (/project/node_modules/graphql/language/visitor.js:332:29)",

                        "    at Object.enter (/project/node_modules/graphql/language/visitor.js:383:25)",

                        "    at visit (/project/node_modules/graphql/language/visitor.js:250:26)",

                        "    at Object.validate (/project/node_modules/graphql/validation/validate.js:63:22)",

                        "    at validate (/project/node_modules/apollo-server-core/dist/requestPipeline.js:211:32)",

                        "    at Object.<anonymous> (/project/node_modules/apollo-server-core/dist/requestPipeline.js:124:42)",

                        "    at Generator.next (<anonymous>)",

                    ]

                }

            }

        }

    ]

}


守着一只汪
浏览 211回答 1
1回答

江户川乱折腾

现在已在Strapi@beta-4 中修复? 错误修复[插件] 在 graphql 模式中加载扩展 (&nbsp;#3417&nbsp;) @alexandrebodin...
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript