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

edges returned from transactions do not represent current state #121

Open
keski opened this issue Oct 5, 2020 · 0 comments
Open

edges returned from transactions do not represent current state #121

keski opened this issue Oct 5, 2020 · 0 comments
Assignees
Labels
backlog Keep open for later (typically, not a problem for SPIRIT but maybe for other woo.sh projects) invalid This doesn't seem right

Comments

@keski
Copy link
Collaborator

keski commented Oct 5, 2020

When executing a transaction the current implementation queries for returned edges after the entire transaction has finished. This means that any intermediate edges queried will represent only the final state.

For example, assume the DB schema below:

type Blog {
    text: String!
    author: Blogger!
}

type Blogger {
    name: String!
}

We create a Blog post using:

mutation {
  createBlog(data: { text: "This is a blog post", author: { create: { name: "John Doe" } } }){
    id
    author {
      id
      name
    }
  }
}

which returns:

{
  createBlog: {
    id: "Blog/123",
    author: {
      id: "Blogger/123",
      name: "John Doe"
    }
  }
}

Let's say we now update the Blog and Blogger in the same mutation request:

mutation {
  updateBlog(id:"Blog/123", data: { text: "This blog has been updated!" }){
    text
    author: {
      name
    }
  }
  m1: updateBlogger(id:"Blogger/123", data: { name: "Alice" }){
    name
  }
  m2: updateBlogger(id:"Blogger/123", data: { name: "Bob" }){
    name
  }
  m3: updateBlogger(id:"Blogger/123", data: { name: "Charlie" }){
    name
  }
}

This will return:

{
  updateBlog: {
    text: "This blog has been updated!",
    author: {
      name: "Charlie" // should still be "John Doe"!
    }
  }
  m1: { name: "Alice" },
  m2: { name: "Bob" },
  m3:  { name: "Charlie" }
}
@keski keski added invalid This doesn't seem right backlog Keep open for later (typically, not a problem for SPIRIT but maybe for other woo.sh projects) labels Oct 5, 2020
@keski keski self-assigned this Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Keep open for later (typically, not a problem for SPIRIT but maybe for other woo.sh projects) invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant