dgraph
dgraph copied to clipboard
Support GraphQL variables in mutations
Experience Report
What you wanted to do
I want to perform a mutation in an upsert block using user-provided data safely.
What you actually did
upsert ($name: string){
query {
var(func: eq(xid, "http://schema.org/Person")) {
Type as uid
}
var(func: eq(<http://schema.org/name>, "Robin Wright")) {
Person as uid
}
}
mutation {
set {
uid(Person) <xid> "https://www.themoviedb.org/person/32-robin-wright" .
uid(Person) <http://schema.org/type> uid(Type) .
uid(Person) <http://schema.org/name> $name .
uid(Person) <dgraph.type> "Person" .
}
}
}
Why that wasn't great, with examples
GraphQL variables are not supported in mutations, so it's impossible to safely mutate user-provided data without error-prone validation.
Any external references to support your case
None at the moment.
I also support this request. The rationale is the same as for GraphQL variables in queries: https://docs.dgraph.io/query-language/#graphql-variables
This looks like a reasonable feature request.
I'm tagging it as accepted, which means it will get into our backlog of features to consider.
If we decide to implement it, we'll post an update here.
Github issues have been deprecated. This issue has been moved to discuss. You can follow the conversation there and also subscribe to updates by changing your notification preferences.
