我们刚刚将项目升级到Strapi版本3-beta,并且在user
中为/extensions/users-permissions/config/schema.graphql
模型定义的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>)",
" at fulfilled (/project/node_modules/apollo-server-core/dist/requestPipeline.js:4:58)",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
}
}
]
}