没有名为public"的可执行架构可用.你设置了'@keystonejs/app-graphql'吗?这似乎与下面的日志矛盾.我做错了什么?console.log(context) 输出:{架构名称:'公共',已认证项目:未定义,authedListKey:未定义,getCustomAccessControlForUser: [功能: getCustomAccessControlForUser],getListAccessControlForUser: [功能: getListAccessControlForUser],getFieldAccessControlForUser: [功能: getFieldAccessControlForUser],getAuthAccessControlForUser:[功能:getAuthAccessControlForUser],总结果: 0,maxTotalResults: 1000,创建上下文:[功能],executeGraphQL: [功能],gqlNames: [功能]} 解决方案 问题的原因似乎是我使用单独的 Express 实例处理 GET 请求,除了基石.解决方案是将我所有的 Express 逻辑(例如自定义端点)添加到 Keystone index.js 文件中的 configureExpress 导出,按照这些说明.自定义服务器 可以设置为更复杂的实现.I need to add some custom server-side functions to my KeystoneJS instance. Below is a simple example; the function userCount has been added to the exports of the file that initialises Keystone, which should return a count of the number of users.module.exports = { keystone, apps: [ new GraphQLApp(), new AdminUIApp({ name: PROJECT_NAME, enableDefaultRoute: true, authStrategy, }), ], userCount: async () => { try { const context = keystone.createContext({ skipAccessControl: true }); console.log(context); // Output below const userCount = await keystone.executeGraphQL({ context, query: `query { _allUsersMeta { count } }`, }); return userCount; } catch (error) { return error; } }};Context seems to be correctly created with the schema name public (see console log below), but no matter what I try, I get the following error:No executable schema named 'public' is available. Have you setup '@keystonejs/app-graphql'?This seems to contradict the log below. What am I doing wrong?console.log(context) output:{ schemaName: 'public', authedItem: undefined, authedListKey: undefined, getCustomAccessControlForUser: [Function: getCustomAccessControlForUser], getListAccessControlForUser: [Function: getListAccessControlForUser], getFieldAccessControlForUser: [Function: getFieldAccessControlForUser], getAuthAccessControlForUser: [Function: getAuthAccessControlForUser], totalResults: 0, maxTotalResults: 1000, createContext: [Function], executeGraphQL: [Function], gqlNames: [Function]} 解决方案 The cause of the problem seems to be that I was handling GET requests with a separate Express instance, which I'd set up in addition to the instance used by Keystone.The solution was to add all my Express logic (e.g. custom endpoints) to the configureExpress export in the Keystone index.js file, as per these instructions.A custom server can be setup for more complicated implementations. 这篇关于自定义 Keystonejs 服务器端函数:“没有名为‘public’的可执行模式";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!