# Return relationships-with-properties as Query results

**URL:** <https://community.neo4j.com/t/return-relationships-with-properties-as-query-results/6559>\
**Category:** GraphQL & GRANDstack\
**Tags:** graphql\
**Created:** [April 12, 2019, 5:56pm UTC](https://community.neo4j.com/t/return-relationships-with-properties-as-query-results/6559 "2019-04-12T17:56:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![npatel](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/npatel/32/4111_2.png) [@npatel](https://community.neo4j.com/u/npatel)\
**Post date:** [April 12, 2019, 5:56pm UTC](https://community.neo4j.com/t/return-relationships-with-properties-as-query-results/6559/1 "2019-04-12T17:56:14Z")

</div>

Hi,

I have a graph network with relationship having properties. So i have modeled them as separate relationship `type`. Normally cypher would be `(u1:User)-[:HAS_ACCESS_TO {role: "readOnly"]-(e1)`  
and there are separate nodes that define what permissions each role has  
`(readOnly:Role {permissions: ['READ_A', 'READ_B']}`

Now when I query to get user and their roles & permissions together, I had to design schema  
something like this

```auto
type User {
    id: ID!
    name: String
    has_access_to: [HasAccessTo]
  }

  type HasAccessTo @relation(name: "HAS_ACCESS_TO") {
      from: User
      to: Entity
      role: String
      permissions: [String]
        @cypher(
          statement: "MATCH (u:UserRole) WHERE u.name = this.role RETURN u.permissions"
        )
  }

```

This approach works when I query something like this

```auto
{
 User(id: "u1") {
  has_access_to {
    role
    permissions
    Entity {
      id
    }
  }
 } 
}

```

But If I have a custom query where I want to return relationships

```auto
type Query {  
    getUserEntities(id: String!, vendorId: Int!): [HasAccessTo]
      @cypher(
        statement: "Match (u:User {id: $id})-[rel:HAS_ACCESS_TO]-(e)-[*0..2]-(v:Vendor {id: $entityId }) return rel"
      )

```

and query

```auto
{
getUserEntities(id: "u1" vendorId: 21989) {
    role 
   permissions
 }
}

```

I get error

```auto
 "message": "Variable `hasAccessTo_relation` not defined (line 1, column 385 (offset: 384))\r\n\"WITH apoc.cypher.runFirstColumn(\"Match (u:User {id: $id})-[rel:HAS_ACCESS_TO]-(e)-[*0..2]-(v:Vendor {id: $vendorId }) return rel\", {offset:$offset, first:$first, id:$id, vendorId:$vendorId}, True) AS x UNWIND x AS `hasAccessTo` RETURN `hasAccessTo` { .role ,permissions: apoc.cypher.runFirstColumn(\"MATCH (u:UserRole) WHERE u.name = this.role RETURN u.permissions\", {this: hasAccessTo_relation}, false)} AS `hasAccessTo` SKIP $offset\"\r\n ^",

```

This might not be the best way so any different suggestions are welcome 🙂

Thanks.
