I am just getting into working with GRANDStack and have found building out a schema to be really intuitive and enjoyable to work with.
However, I am trying to follow the example from the docs for creating a relationship as a type, as I seed my Neo4j instance. This is the example code:
type Movie {
title: String
year: Int
ratings: [Rated]
}
type User {
userId: ID
name: String
rated: [Rated]
}
type Rated @relation(name: "RATED") {
from: User
to: Movie
rating: Float
timestamp: Int
}
The mutations I am using are
export default /* GraphQL */ `
mutation {
movie1: CreateMovie (
title: "First Movie Title"
year: 1998
) {
title
year
}
user1: CreateUser (
userId: "user1"
name: "Gumby"
) {
userId
name
}
userrating1: AddMovieRatings (
from: {userId: "user1"}
to: {id: "246"}
rating: 4.0
timestamp: 2020
) {
rating
timestamp
}
}
`;
I can add a movie and a user, but Apollo gives me a 400 error when running the seedDb script that indicates (in my limited experience) that something is wrong with the AddMovieRatings mutation. Since seedDb only breaks after I add that mutation to the code.
I have the following mutations, and I have tried using the AddUserRated mutation but get same error result. These are the auto generated mutations in the schema
type Mutation {
CreateMovie(title: String, year: Int): Movie
UpdateMovie(title: String!, year: Int): Movie
DeleteMovie(title: String!): Movie
AddMovieRatings(
from: _UserInput!
to: _MovieInput!
data: _RatedInput!
): _AddMovieRatingsPayload
RemoveMovieRatings(
from: _UserInput!
to: _MovieInput!
): _RemoveMovieRatingsPayload
CreateUser(userId: ID, name: String): User
UpdateUser(userId: ID!, name: String): User
DeleteUser(userId: ID!): User
AddUserRated(
from: _UserInput!
to: _MovieInput!
data: _RatedInput!
): _AddUserRatedPayload
RemoveUserRated(from: _UserInput!, to: _MovieInput!): _RemoveUserRatedPayload
}
I think I am missing something simple here? Thanks for any help
For clarification, I mean I am not calling the AddMovieRatings mutation correctly (not that there is something wrong with the mutation itself)
I have tried using the data prop like this too, with no luck:
You can try running your query in GraphQL Playground (just open the GraphQL URL in a web browser) which will give you better error messages, auto-complete, as well as a way to inspect the schema to see what operations / arguments are available.