Open inf3rnus opened 4 years ago
Have you tried doing something like this?
input ThingInput {
id: ID
title: String
description: String
}
type Mutation {
mergeThing(payload: ThingInput!): Thing @cypher(
statement: """
MERGE (thing:Thing $payload)
ON CREATE SET thing.id = apoc.create,uuid()
RETURN thing
"""
)
}
Haven't had a chance to verify how the composite GraphQL argument is stored/provided as a parameter to the cypher query, but it looks like you should be able to use the parameter in place of the literal map for node merging (https://neo4j.com/docs/cypher-manual/current/syntax/parameters/). This seems like it would include only the attributes that are supplied in your payload.
Yes, ^^^ this should work. I'll make an issue to include an example of input type argument in the cos.
Hi again, is it possible to use only a subset of all of the arguments you pass into a @cypher directive mutation?
I can't seem to get this to work without putting in all of the arguments in to match the parameters in the cypher statement.
Is there a way to default values to null or something of that effect?
e.g.
type Mutation { mergeThing( id: ID title: String, description: String ): Thing @cypher( statement: """ MERGE (thing: Thing {title: $title, description: $description}) ON CREATE SET thing.id = apoc.create.uuid() RETURN thing """ )