cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Neo4j GraphQL Library how to use @auth with allow across relationship properties

DevDan
Node Link

I see in the documentation (https://neo4j.com/docs/graphql-manual/current/auth/authorization/allow/), you can use auth with allow across relationship.

However, I want to add read and edit properties on the relationship. 

For example:

type User {
  id: ID! @id(autogenerate: true)
  authId: String! @unique
  objects: [Object!]!
    @relationship(type: "ACCESS", direction: OUT, properties: "Access")
}

type Object {
  id: ID! @id(autogenerate: true)
  users: [User!]!
    @relationship(type: "ACCESS", direction: IN, properties: "Access")
}

interface Access @relationshipProperties {
  edit: Boolean!
}
 
How do I setup my auth rules on object so that read operations is allowed for [:ACCESS] and edit operations is allowed for [:ACCESS {edit: true}].
 
Given the current documentation, it seems I need to create two relationships [:EDIT] and [:READ] for things to work, but that will complicate all my queries when dealing with user's objects.
 
1 REPLY 1

Hey, I had a similar situation here: https://www.reddit.com/r/Neo4j/

What people responded on the discord:

- The where clause transcribes to a cypher "all" clause so if only some of the where conditions are matched in the different relationships, then it will not work.

- To access a relationship property there seems to be no way of doing this right now inside @auth so the best solution for this is to make a custom resolver and pass some custom cypher that checks for the relationship property in there.

Late but hope that helps 🙂