cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Mutation for creating relationship

export const typeDefs = `
type University {
  id: ID!
  level: Int
}
type Department {
  id: ID!
  name: String
  level: Int
  has: [Position] @relation(name: "HAS", direction: "OUT")
  childsof: [Department] @relation(name: "CHILD_OF", direction: "IN")
}
type Position {
  id: ID! 
  name: String
  level: Int
  type: String
}
type Query {
    universities(id: ID, level: Int, first: Int = 10, offset: Int = 0): [University]
    departments(id: ID, name: String, level: Int, first: Int = 10, offset: Int = 0): [Department]
    positions(id: ID, name: String, level: Int, type: String, first: Int = 10, offset: Int = 0): [Position]
}

Here's the schema of my application. I want my :Department node to have a relationship of 'CHILD_OF' i.e. in Cypher this is what I want - a1:Department -[:CHILD_OF]-> a2:Department but I' m unable to do so.
Can anyone tell me how it's done using neo4j-graphql-js

The graphQL generated a mutation based on the relationship given above. For the department's child of relationship it has created an addChildOf but the parameter it is giving is only one and it's of department.

1 ACCEPTED SOLUTION


to be specific

View solution in original post

3 REPLIES 3

William_Lyon
Graph Fellow

You can add auto-generated mutations to your schema by calling augmentSchema, passing in your schema object. Here's an example: https://github.com/neo4j-graphql/neo4j-graphql-js/blob/master/example/apollo-server/movies-middlewar...

Hey William,
Sorry for late reply but the solution you're proposing is already been done.
You can take a look at the code @ https://github.com/thepiperpied/palm-tree


to be specific