You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Strapi 3-beta自定义GraphQL Schema失效问题求助

Fix for Custom GraphQL Query Not Working After Strapi 3-beta Upgrade

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:

  1. Move your schema file to the new required path
    Strapi 3-beta now expects custom plugin GraphQL schemas to live in a dedicated graphql folder within the plugin extension directory. Create (or move your existing file to):
    ./extensions/users-permissions/graphql/schema.graphql

  2. Update 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 resolverOf field is the new recommended way to link to existing plugin handlers, replacing the old plugin/handler object structure.

  3. 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:04:43