KeystoneJS 中意外的字段访问控制行为

问题描述

我正在尝试按照 these instructionskeystonejs 中应用字段级访问逻辑。

以下内容在管理 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,create: ({ authentication: { item,listKey } }) => {
      return false;
    }
  },

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

解决方法

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

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

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