Without UID, updating edges / relationship with GraphQL

In the official documentation, here, it is presented an example of updating two nodes relationship by an edge using GraphQL mutation.

The mutation used is:

mutation updateAuthorWithExistingPost($patch: UpdateAuthorInput!) {
  updateAuthor(input: $patch) {

with the variables:

{ "patch":
  { "filter": {
      "id": ["0x123"]
    "set": {
      "posts": [
          "postID": "0x456"

What I’m wondering is, without knowing the author’s UID, one could use the filter: "filter": {"name": {"eq": "some_author_name"}}, to reference the right author.

But what about the post? Where one would put the filter to reference the post without knowing its UID? Is it possible to create the edge with one single query-mutation with GraphQL? Or is this the situation where DQL comes into play?

One query to collect UIDs and then the mutation with the UIDs.

Only in DQL. Not sure if we already support variables in GraphQL(Only with Vars and multiple blocks this would be possible, but the GraphQL Spec doesn’t support variables neither multiple blocks in the same request or Query + Mutation request). But as the concept is a bit complex, I think we don’t have it for now. I know that we have a ticket tracking this.

Only Upsert Block would do this trick. And we don’t have mutations in a custom DQL query in GraphQL. Not sure how you would do it. Maybe a lambda? maybe a webhook?

The best is do the usual. A query and then a mutation.


1 Like