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

feat: variable batching #3198

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

feat: variable batching #3198

wants to merge 1 commit into from

Conversation

ardatan
Copy link
Collaborator

@ardatan ardatan commented Mar 12, 2024

Implementation of Variable Batching;
graphql/composite-schemas-spec#25

Copy link

changeset-bot bot commented Mar 12, 2024

🦋 Changeset detected

Latest commit: d9c4bf9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
graphql-yoga Minor
@graphql-yoga/nestjs Major
@graphql-yoga/render-graphiql Major
@graphql-yoga/plugin-apollo-inline-trace Major
@graphql-yoga/plugin-apq Major
@graphql-yoga/plugin-csrf-prevention Major
@graphql-yoga/plugin-defer-stream Major
@graphql-yoga/plugin-disable-introspection Major
@graphql-yoga/plugin-graphql-sse Major
@graphql-yoga/plugin-jwt Major
@graphql-yoga/plugin-persisted-operations Major
@graphql-yoga/plugin-prometheus Major
@graphql-yoga/plugin-response-cache Major
@graphql-yoga/plugin-sofa Major
apollo-federation-gateway-with-yoga Patch
apollo-subgraph-with-yoga Patch
graphql-lambda Patch
cloudflare-advanced Patch
cloudflare Patch
functions Patch
hackernews Patch
nextjs-app Patch
hello-world-benchmark Patch
@graphql-yoga/nestjs-federation Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Mar 12, 2024

🚀 Snapshot Release (rc)

The latest changes of this PR are available as rc on npm (based on the declared changesets):

Package Version Info
graphql-yoga-cloud-run-guide 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/apollo-link 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/urql-exchange 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
graphql-yoga 5.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/nestjs 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/nestjs-federation 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apollo-inline-trace 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apq 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-csrf-prevention 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-defer-stream 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-disable-introspection 2.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-graphql-sse 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-jwt 2.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-persisted-operations 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-prometheus 4.1.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-response-cache 3.4.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-sofa 3.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎
@graphql-yoga/render-graphiql 5.2.0-rc-20240312110020-d9c4bf98 npm ↗︎ unpkg ↗︎

Copy link
Contributor

Apollo Federation Subgraph Compatibility Results

Federation 1 Support Federation 2 Support
_service🟢
@key (single)🟢
@key (multi)🟢
@key (composite)🟢
repeatable @key🟢
@requires🟢
@provides🟢
federated tracing🟢
@link🟢
@shareable🟢
@tag🟢
@override🟢
@inaccessible🟢
@composeDirective🟢
@interfaceObject🟢

Learn more:

Copy link
Contributor

💻 Website Preview

The latest changes are available as preview in: https://6863eb74.graphql-yoga.pages.dev

Copy link
Contributor

✅ Benchmark Results

     ✓ no_errors{mode:graphql}
     ✓ expected_result{mode:graphql}
     ✓ no_errors{mode:graphql-jit}
     ✓ expected_result{mode:graphql-jit}
     ✓ no_errors{mode:graphql-response-cache}
     ✓ expected_result{mode:graphql-response-cache}
     ✓ no_errors{mode:graphql-no-parse-validate-cache}
     ✓ expected_result{mode:graphql-no-parse-validate-cache}

     checks.......................................: 100.00% ✓ 409474      ✗ 0     
     data_received................................: 1.7 GB  14 MB/s
     data_sent....................................: 83 MB   689 kB/s
     http_req_blocked.............................: avg=1.41µs   min=992ns    med=1.28µs   max=311.81µs p(90)=1.85µs   p(95)=2.06µs  
     http_req_connecting..........................: avg=2ns      min=0s       med=0s       max=164.65µs p(90)=0s       p(95)=0s      
     http_req_duration............................: avg=376.83µs min=217.86µs med=333.49µs max=17.97ms  p(90)=530.15µs p(95)=550.18µs
       { expected_response:true }.................: avg=376.83µs min=217.86µs med=333.49µs max=17.97ms  p(90)=530.15µs p(95)=550.18µs
     ✓ { mode:graphql-jit }.......................: avg=283.71µs min=217.86µs med=262.77µs max=17.97ms  p(90)=294.01µs p(95)=305.75µs
     ✓ { mode:graphql-no-parse-validate-cache }...: avg=555.69µs min=471.36µs med=529.63µs max=9.74ms   p(90)=570.76µs p(95)=600.69µs
     ✓ { mode:graphql-response-cache }............: avg=359.45µs min=287.1µs  med=339.8µs  max=8.43ms   p(90)=372.83µs p(95)=384.22µs
     ✓ { mode:graphql }...........................: avg=369.77µs min=281.84µs med=337.95µs max=13.08ms  p(90)=380.89µs p(95)=420.48µs
     http_req_failed..............................: 0.00%   ✓ 0           ✗ 204737
     http_req_receiving...........................: avg=32.66µs  min=16.22µs  med=32.7µs   max=1.02ms   p(90)=38.01µs  p(95)=40.11µs 
     http_req_sending.............................: avg=7.92µs   min=5.82µs   med=7.11µs   max=348.61µs p(90)=10.55µs  p(95)=11.23µs 
     http_req_tls_handshaking.....................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting.............................: avg=336.23µs min=186.5µs  med=293.57µs max=17.87ms  p(90)=489.26µs p(95)=507.21µs
     http_reqs....................................: 204737  1706.091398/s
     iteration_duration...........................: avg=581.36µs min=385.79µs med=534.41µs max=18.41ms  p(90)=737.73µs p(95)=761.81µs
     iterations...................................: 204737  1706.091398/s
     vus..........................................: 1       min=1         max=1   
     vus_max......................................: 2       min=2         max=2   

params: GraphQLParams | GraphQLParams[],
): GraphQLParams | GraphQLParams[] {
if (Array.isArray(params)) {
return params.map(param => processBatchedParams(param)).flat();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use flatMap directly instead of chaining map and flat ?

@n1ru4l
Copy link
Collaborator

n1ru4l commented Mar 20, 2024

Lets make this a draft? Or do we want to ship this? We have no real-world use-case..

@kamilkisiela
Copy link
Collaborator

Let's not merge it yet, if so, it should be at least behind a feature flag and marked as experimental.

@n1ru4l n1ru4l marked this pull request as draft March 20, 2024 15:59
@ardatan
Copy link
Collaborator Author

ardatan commented Mar 20, 2024

I agree with @kamilkisiela . It should be behind a flag at least because it conflicts with graphql-http compliance tests.

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

Successfully merging this pull request may close these issues.

None yet

4 participants