[英]Custom GraphQL schema in Strapi#beta.3 is not working
我们刚刚将项目升级到Strapi版本3-beta,我们在/extensions/users-permissions/config/schema.graphql
为user
模型定义的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)"
]
}
}
}
]
}
它现在已在Strapi @ beta-4中修复
🐛错误修复
- [插件]在graphql架构中加载扩展( #3417 )@alexandrebodin
- ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.