YouTag icon indicating copy to clipboard operation
YouTag copied to clipboard

Enables NIO-based Concurrent Execution

Open NeedleInAJayStack opened this issue 10 months ago • 1 comments

The existing concurrent executor was a mix of DispatchQueue.async calls and NIO futures, and was only used on an opt-in basis.

This makes the following changes:

  1. Adds a fully NIO-based concurrent executor
  2. Makes it the default executor used on query and subscription operations
  3. Deprecates APIs that allow specifying particular executors, as well as the DispatchQueue-based executor.

This should better parallelize GraphQL queries by default, resulting in improved performance.

Changes to default values are typically considered major, however this seems to be an exception. The GraphQL spec states the resolvers of queries must be side-effect free and idempotent, the execution order must not affect the result, which means that this can be considered a minor based on the resolver idempotency agreement.

The reasoning for the deprecation is that the JavaScript reference implementation does not expose executor implementations to the caller, instead always executing query and subscription concurrently and mutation serially. Furthermore, Graphiti does not allow customization of executors, implying that it is a rarely used feature.

NeedleInAJayStack avatar Jan 26 '25 05:01 NeedleInAJayStack

Is this good for review?

paulofaria avatar Jan 29 '25 19:01 paulofaria

Any reason you aren't moving to Swift concurrency?

adam-fowler avatar Jun 21 '25 19:06 adam-fowler

Any reason you aren't moving to Swift concurrency?

No, no reason in particular. This was opened back in January, and I was hoping that it would be a pretty small change to align with the intuition of a Concurrent executor.

You make a great point though - if we're going to make a breaking change, I think it makes sense for us to move completely onto Swift Concurrency and drop NIO support. I've started an MR for that here: https://github.com/GraphQLSwift/GraphQL/pull/166 I'd love your feedback!!

NeedleInAJayStack avatar Jun 24 '25 00:06 NeedleInAJayStack

@NeedleInAJayStack can I close this PR?

paulofaria avatar Jul 03 '25 18:07 paulofaria

@paulofaria Yeah, let's close it.

Closing in favor of https://github.com/GraphQLSwift/GraphQL/pull/166

NeedleInAJayStack avatar Jul 04 '25 03:07 NeedleInAJayStack