Graphql schema with multiple relations of same type

schema

(Jan Georg Dev) #1

hello, I'm using the neo4jgraphql npm module and i got a probleme with my schema:

type Person {
    father: Person @relation(name: "FATHER_OF", direction: "OUT")
    mother: Person @relation(name: "MOTHER_OF", direction: "OUT")
}

this fails and i don't get why. If I open Playground I just get: "error": "Response not successful: Received status code 400". When I delete one of them it works. But as soon as two relations retriev the same type it fails. Can somebody help me out or tell me how i could get more than a code 400 error?

Update:
I got the errormessange:

{
  "error": {
    "errors": [
      {
        "message": "Field Mutation.AddPersonPerson can only be defined once.\n\nField Mutation.RemovePersonPerson can only be defined once.",
        "extensions": {
          "code": "GRAPHQL_VALIDATION_FAILED",
          "exception": {
            "stacktrace": [
              "Error: Field Mutation.AddPersonPerson can only be defined once.",
              "Field Mutation.RemovePersonPerson can only be defined once."
            ]
          }
        }
      }
    ]
  }
}

see: https://github.com/neo4j-graphql/neo4j-graphql-js/issues/92


(Shreyansh Zazz) #3

Hey, there

I was having a similar kind of issue lately, and find out that this is a bug in neo4j-graphql-js
One thing you can do is create the custom mutation for these relationships. for example

 AddFather(fatherId: ID!, childId: ID!, count: Int): Person @cypher(
  statement:"""
     MATCH (fatherId:Person {id: $fatherId})
     MATCH (childId:Person {id: $chilId})
     CREATE (fatherId)-[r:FATHER_OF]->(childId)
     SET r.count = $count
     RETURN fatherId
    """)