【问题标题】:Unexpected field access control behaviour in KeystoneJSKeystoneJS 中的意外字段访问控制行为
【发布时间】:2021-01-18 03:00:19
【问题描述】:

我正在尝试根据these instructions 在 KeystoneJS 中应用字段级访问逻辑。

以下内容在管理 UI 中隐藏了一个字段 fieldName

fieldName: {
  type: Text,
  access: {
    read: false,
    update: false,
    create: false
  },
},

但如果我使用imperative approach,则该字段不会从管理 UI 中隐藏。见下文,我希望它产生与上述静态方法相同的结果:

fieldName: {
  type: Text,
  access: {
    read: ({ authentication: { item, listKey } }) => {
      return false;
    },
    update: ({ authentication: { item, listKey } }) => {
      return false;
    },
    create: ({ authentication: { item, listKey } }) => {
      return false;
    }
  },
},

是我遗漏了什么还是这是一个错误?

【问题讨论】:

    标签: javascript node.js keystonejs


    【解决方案1】:

    命令式方法使用了一个不能转移到客户端的函数。

    Keystone 可能为此使用 true false 值。这意味着!!(() => {}) 在为列表中的字段生成管理 ui 元数据时变为真。

    "Granular Imperative Boolean" 部分中有一条注释说明这些字段确实包含在 graphql 和 ui 中,但在执行期间被排除在外。

    【讨论】:

    猜你喜欢
    • 2023-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-21
    • 2012-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多