Skip to content

The learning section for Mutation is missing example for both Update and Upsert #992

Closed
@StingyJack

Description

@StingyJack

https://graphql.org/learn/queries/#mutations

Description

I cant find any information about how to craft an update; how does graphql identify what the target(s) of the update are?

The example code is just a create (which is still unclear to me what each of these parts is)

# mutation statement
mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {
  createReview(episode: $ep, review: $review) {
    stars
    commentary
  }
}
# parameters
{
  "ep": "JEDI",
  "review": {
    "stars": 5,
    "commentary": "This is a great movie!"
  }
}

# result
{
  "data": {
    "createReview": {
      "stars": 5,
      "commentary": "This is a great movie!"
    }
  }
}

What exactly happened here?

  • $ep : JEDI was specified but how was it used?
  • What does the record look like before and after this operation?
  • What information on this mutation informs if this is
    • added as a new record
    • appends data to an existing record
    • replaces an existing record in part or whole?
  • In the case of an update, how is the record(s) to receive the update identified in this example?

Its also missing any mention of an upsert (if exists then update, else insert). Is that missing because its just not possible?

Motivation

My team would like to use GraphQL as an intermediary language to several backend databases instead of having to know the QL for each specific backend. I am trying to write the POC for this "translator" and I think I have a handle on data retrieval, but the available materials for mutations are either incomplete or create more questions.

Collaboration

I'm too much of a noob to be useful in this regard.

Additional Context

This section also makes the statement

While query fields are executed in parallel, mutation fields run in series, one after the other.

Which sounds like it would be an implementation dependent thing, and very inefficient. I interpret that as having some kind of business document that has Author First Name, Middle Initial, and Last Name as three fields, and if I need to change the author to someone else, the system is expected to update the First Name, then the Middle Initial, then the Last Name. To me that sounds kind of awful as it could update only 1 or 2 of the fields but not all of them. Is my interpretation correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions