Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
StingyJack opened this issue Dec 15, 2020 · 1 comment

Comments

@StingyJack
Copy link

StingyJack commented Dec 15, 2020

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?

@StingyJack
Copy link
Author

I'm going to leave this open as someone may find value in it or any answer that can be provided, but we are stopping our POC of using GraphQL because even though by name it is a query language, the spec and everything after the first tutorial shows that it is at best an incomplete query language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant