cancel
Showing results for 
Search instead for 
Did you mean: 

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

jimmyfac1
Node

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
    @cypher(
      statement: """
      MATCH (u:User {id: $auth.jwt.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?

0 REPLIES 0
Nodes 2022
Nodes
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.