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

enable batch execution #1971

Merged
merged 2 commits into from
Sep 1, 2020
Merged

enable batch execution #1971

merged 2 commits into from
Sep 1, 2020

Conversation

yaacovCR
Copy link
Collaborator

@yaacovCR yaacovCR commented Aug 31, 2020

When batch is set to true for a given subschemaConfig, batches all delegated root fields into a combined request passed to the executor. Moreover, batches all requests to a given subschema into the minimum number of requests, collecting queries and mutations separately, preserving operation order. Distributes properly pathed errors to the originating requests.

Adapted from Gatsby query batcher by @vladar.

Caveats:

  • Uses a Dataloader under the hood, which is created anew upon each request -- relies on a unique context argument per request to make this happen!
  • Passed info argument from first executor call to the batched executor call, making info argument unreliable.

Related:

gatsbyjs/gatsby#22347 (comment)
#1710 (comment)
#1959 (comment)
#1954

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 31, 2020

The latest changes of this PR are available as alpha in npm: 6.1.1-alpha-0d5c5f7d.0

Quickly update your package.json by running:

npx match-version @graphql-tools 6.1.1-alpha-0d5c5f7d.0

@yaacovCR yaacovCR force-pushed the batch-execution branch 7 times, most recently from 0c92998 to 2a6bab9 Compare August 31, 2020 20:13
When `batch` is set to true for a given subschemaConfig, batches all delegated root fields into a combined request passed to the executor. Moreover, batches all requests to a given subschema into the minimum number of requests, collecting queries and mutations separately, preserving operation order. Distributes properly pathed errors to the originating requests.

Adapted from Gatsby query batcher by @vladar.

Caveats:
* Uses a Dataloader under the hood, which is created anew upon each request -- relies on a unique context argument per request to make this happen!
* Passed `info` argument from first executor call to the batched executor call, making info argument unreliable.

Related:

gatsbyjs/gatsby#22347 (comment)
#1710 (comment)
#1959 (comment)
#1954
@ardatan ardatan added the feature New addition or enhancement to existing solutions label Sep 1, 2020
@ardatan ardatan merged commit 0c0b89f into master Sep 1, 2020
@ardatan ardatan deleted the batch-execution branch September 1, 2020 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New addition or enhancement to existing solutions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants