Strapi 3-beta自定义GraphQL Schema失效问题求助
I ran into a nearly identical issue when upgrading to Strapi 3-beta, and the root cause is changes to how Strapi loads custom GraphQL schemas for the users-permissions plugin in the beta release. The old file path you used (/extensions/users-permissions/config/schema.graphql) is no longer recognized by the updated plugin system.
Here's how to resolve it step by step:
Move your schema file to the new required path
Strapi 3-beta now expects custom plugin GraphQL schemas to live in a dedicatedgraphqlfolder within the plugin extension directory. Create (or move your existing file to):./extensions/users-permissions/graphql/schema.graphqlUpdate the resolver configuration format
The beta version uses a slightly different resolver syntax to reference existing plugin handlers. Adjust your config file to this structure:module.exports = { query: ` userSearch(_q: String!): [UsersPermissionsUser] `, resolver: { Query: { userSearch: { // Use resolverOf to reference the built-in user search handler resolverOf: "users-permissions.user.search", // Optional: Add custom logic here if you need to modify the response async resolver(_, args) { const users = await strapi.plugin('users-permissions').service('user').search(args); return users; } } } } };The
resolverOffield is the new recommended way to link to existing plugin handlers, replacing the oldplugin/handlerobject structure.Restart your Strapi server
Strapi caches extension configurations on startup, so a full restart is required for the changes to take effect.
Why this broke in the beta:
Strapi 3-beta included a full refactor of its GraphQL system, aligning plugin extension logic with a new modular architecture. The old config/schema.graphql path was deprecated to make way for a more organized directory structure for custom plugin code.
Verify the fix:
After applying these changes, run your original GraphQL query again:
query ($_q: String!) { userSearch(_q: $_q) { id first_name last_name } }
You should no longer see the "Cannot query field 'userSearch'" validation error, and the query should return the expected user data.
内容的提问来源于stack exchange,提问作者Sepehr Hosseini

