Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-01-2022 10:52 PM
Hi there - Currently I have a a large mutation that creates Post
s that could optionally have attributes which sometimes come in the form of linked nodes. So a post might have a body, created_date, and other properties but might also have a creator
which is a connected node.
Sometimes these have rating
s which creates and connects to new Rating
nodes. The problem is, my mutation accepts these variables either way, so whether I have a value for the rating or not, it seems the mutation will create a new Rating
. There are other examples, Rating
is not the only type of connected node that may or may not appear in Post
s.
So my question is: other than creating a new mutation for every combination of variables (there are very many), is there a way to tell the mutation to totally ignore the field if there's no value submitted?
mutation NEW_POST($body: String, $rating: Float) {
createPosts(input: { body: $body, rating: { create: { node: { value: $rating }}}}){
Here is a shortened version of what the NEW_POST looks like. I truncated it for simplicity. Essentially, regardless of $rating
being a value or null, it still creates and connects to a new Rating
node. Any way to tell the system to only create if $rating
exists? It looks like it just creates an empty node when $rating
is empty.
Solved! Go to Solution.
01-01-2022 11:24 PM
Actually this one was solved by passing in variables that were empty objects rather than Float type variables. Instead of having { create: { node: { value: $rating }}}
live in the mutation itself, I optionally send that entire thing when I send my variables. So if no $rating value exists, the mutation receives {} instead of a full create action with no value.
01-01-2022 11:24 PM
Actually this one was solved by passing in variables that were empty objects rather than Float type variables. Instead of having { create: { node: { value: $rating }}}
live in the mutation itself, I optionally send that entire thing when I send my variables. So if no $rating value exists, the mutation receives {} instead of a full create action with no value.
All the sessions of the conference are now available online