基于关系所有者字段的访问控制

时间:2020-02-06 12:13:44

标签: graphql keystonejs

使用keystonejs,我希望仅在当前用户为项目所有者的情况下才允许更新访问。附件中您找到我的方法。我怀疑GraphQlWhere-return Value的语法不太正确。

此外,此刻是否将填充所有者字段?

keystone.createList('Pet', {
  access: {
    update: ({ authentication: { item: user } }) => {
      if (!user) return false;
      return { owner: { id: user.id } }; // <--- HOW TO DO THIS RIGHT?
    };
  },
  fields: {
    name: { type: Text },
    owner: {
      type: Relationship,
      ref: 'User',
    }
  }
})

0 个答案:

没有答案