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(persisted-operations): ability to support different specifications #1610

Merged
merged 6 commits into from
Sep 6, 2022

Conversation

ardatan
Copy link
Collaborator

@ardatan ardatan commented Aug 16, 2022

Drop store in favor of more generic getPersistedOperation that takes key that is generated by getPersistedOperationKey function. The other function takes parsed request body.

This makes Persisted Operations plugin support different specification in a future proof approach. If there is another more "official" spec is introduced by GraphQL, this plugin will be able to support that with a few configuration.

@ardatan ardatan requested a review from n1ru4l August 16, 2022 18:04
@changeset-bot
Copy link

changeset-bot bot commented Aug 16, 2022

🦋 Changeset detected

Latest commit: 4cc2c1e

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

This PR includes changesets to release 15 packages
Name Type
graphql-yoga Minor
@graphql-yoga/common Patch
@graphql-yoga/node Patch
@graphql-yoga/render-graphiql Major
@graphql-yoga/plugin-apollo-inline-trace Major
@graphql-yoga/plugin-apq Major
@graphql-yoga/plugin-persisted-operations Major
@graphql-yoga/plugin-response-cache Major
apollo-federation-gateway-with-yoga Patch
apollo-subgraph-with-yoga Patch
graphql-lambda Patch
cloudflare-advanced Patch
cloudflare Patch
hackernews Patch
hello-world-benchmark 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

@github-actions
Copy link
Contributor

The latest changes of this PR are not available as canary, since there are no linked changesets for this PR.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 16, 2022

✅ Benchmark Results

     ✓ no_errors
     ✓ expected_result

     checks.........................: 100.00% ✓ 105980     ✗ 0    
     data_received..................: 16 MB   526 kB/s
     data_sent......................: 6.1 MB  203 kB/s
     http_req_blocked...............: avg=2.04µs   min=1.1µs    med=1.7µs    max=1.62ms  p(90)=2.29µs   p(95)=2.7µs   
     http_req_connecting............: avg=27ns     min=0s       med=0s       max=1.45ms  p(90)=0s       p(95)=0s      
   ✓ http_req_duration..............: avg=450.47µs min=278.74µs med=389µs    max=24.35ms p(90)=499.51µs p(95)=620.36µs
       { expected_response:true }...: avg=450.47µs min=278.74µs med=389µs    max=24.35ms p(90)=499.51µs p(95)=620.36µs
     http_req_failed................: 0.00%   ✓ 0          ✗ 52990
     http_req_receiving.............: avg=29.53µs  min=17µs     med=24.5µs   max=6.18ms  p(90)=35.5µs   p(95)=41.5µs  
     http_req_sending...............: avg=11.27µs  min=6µs      med=8.1µs    max=3.11ms  p(90)=18.4µs   p(95)=19.9µs  
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s      p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=409.66µs min=250.44µs med=353.01µs max=24.2ms  p(90)=448.31µs p(95)=561.03µs
     http_reqs......................: 52990   1766.22764/s
     iteration_duration.............: avg=559.05µs min=353.61µs med=494.27µs max=26.18ms p(90)=623.51µs p(95)=770.98µs
     iterations.....................: 52990   1766.22764/s
     vus............................: 1       min=1        max=1  
     vus_max........................: 1       min=1        max=1  

@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2022

🚀 Snapshot Release (alpha)

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

Package Version Info
@graphql-yoga/apollo-link 1.0.0-alpha-20220906121446-3de60b56 npm ↗︎ unpkg ↗︎
@graphql-yoga/urql-exchange 1.0.0-alpha-20220906121446-3de60b56 npm ↗︎ unpkg ↗︎
@graphql-yoga/common 3.0.0-alpha-20220906121446-3de60b56 npm ↗︎ unpkg ↗︎
@graphql-yoga/graphiql 2.4.3-alpha-20220906121446-3de60b56 npm ↗︎ unpkg ↗︎
graphql-yoga 3.0.0-alpha-20220906121446-3de60b56 npm ↗︎ unpkg ↗︎
@graphql-yoga/node 3.0.0-alpha-20220906121446-3de60b56 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apollo-inline-trace 1.0.0-alpha-20220906121446-3de60b56 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apq 1.0.0-alpha-20220906121446-3de60b56 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-persisted-operations 1.0.0-alpha-20220906121446-3de60b56 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-response-cache 1.0.0-alpha-20220906121446-3de60b56 npm ↗︎ unpkg ↗︎
@graphql-yoga/render-graphiql 3.0.0-alpha-20220906121446-3de60b56 npm ↗︎ unpkg ↗︎

@ardatan ardatan merged commit f4b2338 into v3 Sep 6, 2022
@ardatan ardatan deleted the relay-persisted branch September 6, 2022 12:12
@benjie
Copy link

benjie commented Sep 6, 2022

In @graphile/persisted-operations we try and use whichever is provided of both:

https://github.com/graphile/persisted-operations/blob/a18b0285a40ad8993c1c16d89392d231d8696527/src/index.ts#L85-L92

function defaultHashFromPayload(payload: RequestPayload) {
  return (
    // https://github.com/apollographql/apollo-link-persisted-queries#protocol
    payload?.extensions?.persistedQuery?.sha256Hash ||
    // https://relay.dev/docs/en/persisted-queries#network-layer-changes
    payload?.documentId
  );
}

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

3 participants