The utility generates or ingests a GraphQL schema, in which input types can be maps. Generating a resolver that inference a single graph query that creates or merge multiple nodes and edges at once, following the map data structure and the schema directives.
Example
The GraphQL schema has a type Person that includes a list of type Todo, and each the Todo includes a list of Comment.
A corresponed set of nested input types: PersonInput, TodoInput, and CommentInput.
The graph database connects the nodes with label person, todo, and comment with edges of type has.
type Person @alias(property: "person") {
firstName: String
todos: [Todo] @relationship(edgeType: "HAS", direction: OUT)
}
type Todo @alias(property: "todo") {
name: String
description: String
priority: Int
status: String
comments: [Comment] @relationship(edgeType: "HAS", direction: OUT)
}
type Comment @alias(property: "comment") {
content: String
}
input PersonInput {
firstName: String
todos: [TodoInput]
}
input TodoInput {
name: String
description: String
priority: Int
status: String
comments: [CommentInput]
}
input CommentInput {
content: String
}
type Mutation {
createNodePerson(input: PersonInput!, merge: [String]): Person
}
type Query {
# Create Poster
getNodePerson(filter: PersonInput): Person
# Create Todo
getNodeTodo(filter: TodoInput): Todo
}
schema {
query: Query
mutation: Mutation
}
The mutation createNodePerson accept as input a map, validated by the nested input types of the schema, like:
mutation MyMutation {
createNodePerson( input: {
firstName: "John",
todos: [
{
name: "code",
comments: [
{content: "I like it"},
{content: "Will do more"}
]
},
{
name: "FAQ",
comments: [
{content: "I like it too"},
{content: "just when I need it"}
]
}
]})
{
firstName
}
}
The resolver will parse the input and based of the schema will create a single openCypher query that creates the nodes and the edges at once.
The option merge toggle if a node type in the map is always created or merged, meaning finding and connecting an existing node. The merge option is a list like ["todos", "todos.comments"].
The utility generates or ingests a GraphQL schema, in which input types can be maps. Generating a resolver that inference a single graph query that creates or merge multiple nodes and edges at once, following the map data structure and the schema directives.
Example The GraphQL schema has a type Person that includes a list of type Todo, and each the Todo includes a list of Comment. A corresponed set of nested input types: PersonInput, TodoInput, and CommentInput. The graph database connects the nodes with label person, todo, and comment with edges of type has.
The mutation createNodePerson accept as input a map, validated by the nested input types of the schema, like:
The resolver will parse the input and based of the schema will create a single openCypher query that creates the nodes and the edges at once.
The option merge toggle if a node type in the map is always created or merged, meaning finding and connecting an existing node. The merge option is a list like ["todos", "todos.comments"].