Showing results for 
Search instead for 
Did you mean: 

Relationship IN and OUT not working as expected with cypher in graphql/neo4j


I'm having an issue creating a relationship the right way, I have these schemas :

type User {
  id: ID!
  mail: String!
  password: String! @private
  meals: [Meal] @relationship(type: "IN_MEALS", direction: IN)

type Meal {
  name: String!
  createdBy: User! @relationship(type: "IN_MEALS", direction: OUT)

And I added this mutation to create a meal directly as one of the current user's like so :

type Mutation {
  createMeal(name: String!): Meal
      statement: """
      MATCH (u:User {id: $})
      MERGE (m:Meal {name: $name})-[r:IN_MEALS]->(u)
      RETURN m

In neo4j databse the relation is made to the user and all seems good but when I query meals of the users or the createdBy field of a meal it shows "null", what am I missing?

Nodes 2022
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.