I was trying to use GraphQL variables, like I would for a GraphQL+/- query, but with an upsert. And it seems there is a bug that makes it not work - don’t know if this is by design or not.
The JSON I am sending to the mutation API -
{
query: "query GetNode($name:string!) {
node(func:type("Node")) @filter(eq(name,$name)) { nodeuid as uid }
}",
set: [{
"dgraph.type": "Node",
"uid": "uid(nodeuid)",
name: "$name"
}],
variables: { "$name": "very special" }
}
So there are a couple of problems with this,
- The “variables” section is not being passed into the query - the value of
$name
is empty. - The appearance of
$name
inside theset [ {} ]
doesn’t work - The query can accept variables, as default parameters
query GetNode($name:string = "special")
works. - But the “mandatory” variable does not work with default parameters, so
query GetNode($name:string! = "special")
throws an error.