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: replace/wrap the logic params handled - ParamsHandler #3736

Merged
merged 6 commits into from
Feb 6, 2025

Conversation

ardatan
Copy link
Collaborator

@ardatan ardatan commented Feb 6, 2025

Now it is possible to replace or wrap the logic how GraphQLParams handled;

By default Yoga calls Envelop to handle the parameters, but now you can replace it with your own logic.

Closes #3734

Fixes YOGA-2

Example: Wrap the GraphQL handling pipeline in an AsyncLocalStorage

function myPlugin(): Plugin {
  const context = new AsyncLocalStorage();
  return {
    onParams({ paramsHandler, setParamsHandler }) {
      const store = { foo: 'bar' }
      setParamsHandler(payload => context.run(store, paramsHandler, payload))
   }
}

Copy link

changeset-bot bot commented Feb 6, 2025

🦋 Changeset detected

Latest commit: 204b558

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/apollo-managed-federation Major
@graphql-yoga/plugin-apollo-usage-report 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
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 Feb 6, 2025

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

github-actions bot commented Feb 6, 2025

💻 Website Preview

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

Copy link
Contributor

github-actions bot commented Feb 6, 2025

✅ 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}
     ✓ no_errors{mode:uws}
     ✓ expected_result{mode:uws}

     checks.......................................: 100.00% ✓ 512710      ✗ 0     
     data_received................................: 2.1 GB  14 MB/s
     data_sent....................................: 103 MB  687 kB/s
     http_req_blocked.............................: avg=1.58µs   min=1.02µs   med=1.36µs   max=494.98µs p(90)=2.08µs   p(95)=2.3µs   
     http_req_connecting..........................: avg=3ns      min=0s       med=0s       max=437.24µs p(90)=0s       p(95)=0s      
     http_req_duration............................: avg=363.77µs min=214.16µs med=331.91µs max=19.12ms  p(90)=477.18µs p(95)=499.41µs
       { expected_response:true }.................: avg=363.77µs min=214.16µs med=331.91µs max=19.12ms  p(90)=477.18µs p(95)=499.41µs
     ✓ { mode:graphql-jit }.......................: avg=287.45µs min=214.16µs med=270.92µs max=19.12ms  p(90)=301.53µs p(95)=314.35µs
     ✓ { mode:graphql-no-parse-validate-cache }...: avg=504.73µs min=417.14µs med=479.43µs max=11.41ms  p(90)=521.31µs p(95)=589.33µs
     ✓ { mode:graphql-response-cache }............: avg=350.44µs min=269.64µs med=333.1µs  max=8.27ms   p(90)=363.71µs p(95)=374.97µs
     ✓ { mode:graphql }...........................: avg=366.57µs min=280.6µs  med=339.65µs max=14.22ms  p(90)=388.34µs p(95)=436.45µs
     ✓ { mode:uws }...............................: avg=350.02µs min=272.44µs med=331.49µs max=6.76ms   p(90)=366.68µs p(95)=389.5µs 
     http_req_failed..............................: 0.00%   ✓ 0           ✗ 256355
     http_req_receiving...........................: avg=34.27µs  min=17.2µs   med=33.71µs  max=2.6ms    p(90)=40.63µs  p(95)=43.62µs 
     http_req_sending.............................: avg=8.91µs   min=5.88µs   med=7.89µs   max=321.34µs p(90)=11.34µs  p(95)=12.46µs 
     http_req_tls_handshaking.....................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting.............................: avg=320.58µs min=182.15µs med=290.06µs max=18.96ms  p(90)=433.23µs p(95)=453.94µs
     http_reqs....................................: 256355  1709.016819/s
     iteration_duration...........................: avg=580.08µs min=386.49µs med=543.52µs max=19.68ms  p(90)=697.44µs p(95)=724.05µs
     iterations...................................: 256355  1709.016819/s
     vus..........................................: 1       min=1         max=2   
     vus_max......................................: 2       min=2         max=2   

@ardatan ardatan requested a review from EmrysMyrddin February 6, 2025 14:19
@ardatan ardatan marked this pull request as ready for review February 6, 2025 14:19
@ardatan ardatan merged commit d13b8a4 into main Feb 6, 2025
15 of 16 checks passed
@ardatan ardatan deleted the onparams-handler branch February 6, 2025 14:25
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.

2 participants