我们刚刚将我们的项目升级到 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>)",
]
}
}
}
]
}
江户川乱折腾
相关分类