Your challenge is to update the GraphQL type definitions from the previous lesson to include the RATED relationship between the User and Movie types.
The RATED relationship includes a rating property, of type float, that holds the user’s rating for the movie.
Run this query in the Neo4j Sandbox to explore the RATED relationship between the User and Movie nodes:
MATCH (u:User)-[r:RATED]->(m:Movie{title: "Matrix, The"}) RETURN u,r,m-
Update the type definitions to create a new
Ratedtype which specifiesratingproperty with an appropriate type.GraphQLtype Rated @relationshipProperties { ... } -
Add the
RATEDrelationship to theUsertype definitionGraphQLtype User @node { userId: ID! name: String! ... } -
Construct a GraphQL query that uses the
RATEDrelationship to return all the ratings for the user "Gloria Nelson".
Click here to reveal the new type definitions
type Rated @relationshipProperties {
rating: Float
}
type User @node {
userId: ID!
name: String!
rated: [Movie!]! @relationship(type: "RATED", properties: "Rated", direction: OUT)
}Click here to reveal the GraphQL query
query MyQuery {
users(where: { name: {eq: "Gloria Nelson" } } ) {
name
ratedConnection {
edges {
properties {
rating
}
node {
title
}
}
}
}
}Summary
In this challenge, you created a new relationship between the User and Movie types and specified a relationship property.
In the next module, you will learn how to create, update, and delete data using GraphQL mutations.