【问题标题】:Strapi GraphQL policiesStrapi GraphQL 策略
【发布时间】:2020-03-09 12:44:13
【问题描述】:

我尝试在 Strapi 项目中使用 GraphQL 模块。我想添加新的查询。你可以看看我的代码:

{
  "routes": [
    {
      "method": "GET",
      "path": "/recipes",
      "handler": "Recipes.recipes"
    }
  ]
}

还有我的架构:

module.exports = {
  definition: `
    type Recipe {
      title: String!
    }
  `,
  query: `
    recipes: Recipe
  `,
  resolver: {
    Query: {
      recipes: {
        description: 'Return a single Recipe',
        resolver: 'Recipes.recipes'
      }
    }
  }
};

我的查询返回错误 403。但是,如果我使用 CURL 命令尝试我的 URL,我得到了正确的响应。

谁知道我是否需要为没有策略的 GraphQL 查询添加其他参数?

谢谢!

【问题讨论】:

    标签: graphql strapi


    【解决方案1】:

    您的路线/receipes 缺少config 键。所以请务必添加它。 然后,当您请求此路由时,请确保您允许您的用户使用此路由。

    这里有一些关于https://strapi.io/documentation/3.0.0-beta.x/plugins/users-permissions.html#manage-roles-permissions的文档

    关于您的 GraphQL 查询 - 这里有一些文档:https://strapi.io/documentation/3.0.0-beta.x/plugins/graphql.html#customise-the-graphql-schema

    【讨论】:

      猜你喜欢
      • 2023-01-17
      • 2018-10-22
      • 2021-03-09
      • 2019-11-13
      • 1970-01-01
      • 2018-10-16
      • 2018-06-04
      • 2020-04-17
      • 2021-05-28
      相关资源
      最近更新 更多