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

Top level fields in mutations should execute in SERIES not parallel #86

Closed
cshadek opened this issue Jul 16, 2021 · 2 comments
Closed

Comments

@cshadek
Copy link

cshadek commented Jul 16, 2021

The GraphQL spec specifies that the top level fields in mutations should execute serially.

http://spec.graphql.org/June2018/#sec-Mutation

When I run a Mutation like the following using Graphiti, I get race conditions and unexpected results. The only explanation I have for this is that they are running in parallel. Am I missing something? Thanks!

mutation Test {
    addLike(input: {id: 1}) {
       ....
    }
    removeLike(input: {id: 1} ) {
       ....
    }
    addLike2: addLike(input: {id: 1} ) {
       ....
    }
}
@NeedleInAJayStack
Copy link
Member

@cshadek Could you provide a more fleshed-out code example that displays the race conditions and unexpected results?

I did some initial testing and was unable to create the data races/unexpected results you describe. The "like" was always added, removed, and then added again without any ID conflict.

Note that while the top-level mutations execute in series, the GraphQL resolution pattern (concurrent or serial) is always outer-to-inner, so the .... field resolvers are not guaranteed to run before the next mutation occurs. The spec reflects this by specifying that only the top level selection set of the mutation is run serially.

@NeedleInAJayStack
Copy link
Member

Resolved by #124

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

2 participants