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.

Retrieve Relationship Properties in a Type query

Hello -

I'm trying to track a relationship between two entities (a review and a tag) with a strength and then be able to easily return all the tags for a review along with their strength. So I currently have:

type Review {
  id: ID!
  stars: Int
  stars_value: Int 
  text: String
  date: DateTime
  user: User @relation(name: "WROTE", direction: "IN")
  tags: [Tagged]
}

type Tag {
  id: ID!
  name: String
  reviews: [Tagged]
}

type Tagged @relation(name: "TAGGED") {
  from: Review
  to: Tag 
  strength: Int
}

When I pull up a Review(or add a new Review), I need to be able see/set each of the tags with their strength. Can't seem to figure out how to ask for strength though. Hopefully I'm missing something easy!

This works fine for returning all reviews with their tags:

{
  Spirit {
    name
    tags {
      name
    }
  }
}

Would appreciate any suggestions or guidance! Or if someone thinks there is a better way to represent this data!

Thanks.

1 ACCEPTED SOLUTION

William_Lyon
Graph Fellow

Hi @cknisley44 -

In this case the strength property is on the relationship and the tag name is on the Tag node. So the GraphQL query to retrieve both the strength and name of the tag, starting from a review, should look like this:

{
  Review(first:1) {
    tags {
      strength
      Tag {
        name
      }
    }
  }
}

The relationship type query api uses the type name, instead of from/to. You can read more about relationship types here: https://grandstack.io/docs/graphql-relationship-types.html

View solution in original post

1 REPLY 1

William_Lyon
Graph Fellow

Hi @cknisley44 -

In this case the strength property is on the relationship and the tag name is on the Tag node. So the GraphQL query to retrieve both the strength and name of the tag, starting from a review, should look like this:

{
  Review(first:1) {
    tags {
      strength
      Tag {
        name
      }
    }
  }
}

The relationship type query api uses the type name, instead of from/to. You can read more about relationship types here: https://grandstack.io/docs/graphql-relationship-types.html