graphql权限连接到自身

时间:2018-09-10 07:10:51

标签: permissions graphql mutation graphcool

我陷入了graphql的困境。 我遵循此https://www.graph.cool/docs/reference/auth/authorization/overview-iegoo0heez

我有这样的架构:

type Card @model { 
  id: ID! @isUnique
  parent: [Card!]! @relation(name: "Parentcards")
  children: [Card!]! @relation(name: "Subcards")
}

我想连接孩子,其中一个卡中有Id1和卡Id2 我用这个:

mutation connectCard($parentId: ID!, $childrenId: ID!) { addToSubcards(children1CardId: $parentId, children2CardId: $childrenId) { children1Card { title } children2Card { title } } } 但是它将自动连接到两侧:

  • Id1Id2
  • 的子级
  • Id2也是Id1的子代

graphcool.yml 中,**权限:**我写道:

  - operation: Card.read
    authenticated: true

  - operation: Card.create
    authenticated: true

  - operation: Card.update
    authenticated: true
    query: ./permissions/updateOrDeleteCard.graphql

  - operation: Card.delete
    authenticated: true
    query: ./permissions/updateOrDeleteCard.graphql

  - operation: Parentcards.connect
    authenticated: true

  - operation: Parentcards.disconnect
    authenticated: true

  - operation: Subcards.connect
    authenticated: true

  - operation: Subcards.disconnect
    authenticated: true

updateOrDeleteCard.graphql 文件中:

query ($node_id: ID!) {
  SomeCardExists(filter: {
    id: $node_id 
  })
}

我尝试了另一种通过列表childIds卡来更新卡子代的方法。但是,当我更新卡时,收到消息:“此突变权限不足”,

所以,这是我的问题,我尝试了两种不同的方法。 请帮助我。

无论如何,非常感谢您!

1 个答案:

答案 0 :(得分:0)

您需要在底部通过

传递授权标题
Authorization : Bearer <TOKEN>

as graphcool docs explained