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

Introduce 'batch' flag, improve loadSchema and merge wrapped schemas properly #4535

Merged
merged 3 commits into from Jun 23, 2022

Conversation

ardatan
Copy link
Owner

@ardatan ardatan commented Jun 23, 2022

loadSchema;
No longer call mergeSchemas if a single schema is loaded.
Previously all typeDefs and resolvers were extracted and the schema was rebuilt from scratch.
But this is not necessary if there is only one schema loaded with loadSchema

mergeSchemas was skipping defaultFieldResolver and defaultMergedResolver by default while extracting resolvers for each given schema to reduce the overhead. But this doesn't work properly if you mix wrapped schemas and local schemas. So new includeDefaultMergedResolver flag is introduced in getResolversFromSchema to put default "proxy" resolvers in the extracted resolver map for mergeSchemas.

This fixes an issue with alias issue, so nested aliased fields weren't resolved properly because of the missing defaultMergedResolver in the final merged schema which should come from the wrapped schema.

UrlLoader:
New 'batch' flag! Now you can configure your remote schema to batch parallel queries to the upstream.

Closes: #3267

@changeset-bot
Copy link

changeset-bot bot commented Jun 23, 2022

🦋 Changeset detected

Latest commit: 7db66bf

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

This PR includes changesets to release 28 packages
Name Type
@graphql-tools/load Minor
@graphql-tools/schema Minor
@graphql-tools/utils Minor
@graphql-tools/url-loader Minor
@graphql-tools/node-require Patch
@graphql-tools/batch-delegate Patch
@graphql-tools/delegate Patch
graphql-tools Patch
@graphql-tools/mock Patch
@graphql-tools/stitch Patch
@graphql-tools/stitching-directives Patch
@graphql-tools/wrap Patch
@graphql-tools/batch-execute Patch
@graphql-tools/graphql-tag-pluck Patch
@graphql-tools/import Patch
@graphql-tools/links Patch
@graphql-tools/merge Patch
@graphql-tools/relay-operation-optimizer Patch
@graphql-tools/resolvers-composition Patch
@graphql-tools/apollo-engine-loader Patch
@graphql-tools/code-file-loader Patch
@graphql-tools/git-loader Patch
@graphql-tools/github-loader Patch
@graphql-tools/graphql-file-loader Patch
@graphql-tools/json-file-loader Patch
@graphql-tools/module-loader Patch
@graphql-tools/prisma-loader Patch
federation-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

@vercel
Copy link

vercel bot commented Jun 23, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
graphql-tools ❌ Failed (Inspect) Jun 23, 2022 at 10:54AM (UTC)

@theguild-bot
Copy link
Collaborator

theguild-bot commented Jun 23, 2022

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

@graphql-tools/batch-delegate@8.2.21-alpha-bdd7f13e.0
@graphql-tools/batch-execute@8.4.11-alpha-bdd7f13e.0
@graphql-tools/delegate@8.7.12-alpha-bdd7f13e.0
@graphql-tools/graphql-tag-pluck@7.2.11-alpha-bdd7f13e.0
graphql-tools@8.2.13-alpha-bdd7f13e.0
@graphql-tools/import@6.6.18-alpha-bdd7f13e.0
@graphql-tools/links@8.2.19-alpha-bdd7f13e.0
@graphql-tools/load@7.6.0-alpha-bdd7f13e.0
@graphql-tools/apollo-engine-loader@7.2.20-alpha-bdd7f13e.0
@graphql-tools/code-file-loader@7.2.19-alpha-bdd7f13e.0
@graphql-tools/git-loader@7.1.18-alpha-bdd7f13e.0
@graphql-tools/github-loader@7.2.24-alpha-bdd7f13e.0
@graphql-tools/graphql-file-loader@7.3.16-alpha-bdd7f13e.0
@graphql-tools/json-file-loader@7.3.16-alpha-bdd7f13e.0
@graphql-tools/module-loader@7.1.14-alpha-bdd7f13e.0
@graphql-tools/prisma-loader@7.1.25-alpha-bdd7f13e.0
@graphql-tools/url-loader@7.10.0-alpha-bdd7f13e.0
@graphql-tools/merge@8.2.15-alpha-bdd7f13e.0
@graphql-tools/mock@8.6.13-alpha-bdd7f13e.0
@graphql-tools/node-require@6.3.15-alpha-bdd7f13e.0
@graphql-tools/relay-operation-optimizer@6.4.15-alpha-bdd7f13e.0
@graphql-tools/resolvers-composition@6.4.14-alpha-bdd7f13e.0
@graphql-tools/schema@8.4.0-alpha-bdd7f13e.0
@graphql-tools/stitch@8.6.14-alpha-bdd7f13e.0
@graphql-tools/stitching-directives@2.2.19-alpha-bdd7f13e.0
@graphql-tools/utils@8.7.0-alpha-bdd7f13e.0
@graphql-tools/wrap@8.4.21-alpha-bdd7f13e.0

@github-actions
Copy link
Contributor

github-actions bot commented Jun 23, 2022

❌ Benchmark Failed

Performance regression detected: it seems like your Pull Request adds some extra latency to Schema Stitching

If the performance regression is expected, please increase the failing threshold.

     ✓ no_errors
     ✓ expected_result

     checks.........................: 100.00% ✓ 208       ✗ 0  
     data_received..................: 24 MB   2.4 MB/s
     data_sent......................: 89 kB   8.8 kB/s
     http_req_blocked...............: avg=6.15µs   min=3µs     med=3.5µs    max=233.8µs  p(90)=4.2µs    p(95)=5.08µs  
     http_req_connecting............: avg=1.68µs   min=0s      med=0s       max=175.7µs  p(90)=0s       p(95)=0s      
   ✗ http_req_duration..............: avg=90.42ms  min=72.52ms med=85.28ms  max=204.83ms p(90)=98.17ms  p(95)=134.84ms
       { expected_response:true }...: avg=90.42ms  min=72.52ms med=85.28ms  max=204.83ms p(90)=98.17ms  p(95)=134.84ms
     http_req_failed................: 0.00%   ✓ 0         ✗ 104
     http_req_receiving.............: avg=208.19µs min=143.7µs med=200.45µs max=401.5µs  p(90)=263.25µs p(95)=284.87µs
     http_req_sending...............: avg=144.4µs  min=18.3µs  med=29.1µs   max=2.69ms   p(90)=74.34µs  p(95)=1.27ms  
     http_req_tls_handshaking.......: avg=0s       min=0s      med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=90.07ms  min=72.35ms med=85.03ms  max=204.37ms p(90)=96.66ms  p(95)=134.63ms
     http_reqs......................: 104     10.316763/s
     iteration_duration.............: avg=96.89ms  min=77.84ms med=91.22ms  max=210.91ms p(90)=106.67ms p(95)=144.12ms
     iterations.....................: 104     10.316763/s
     vus............................: 1       min=1       max=1
     vus_max........................: 1       min=1       max=1

@ardatan ardatan merged commit 4914970 into master Jun 23, 2022
@ardatan ardatan deleted the fix-alias branch June 23, 2022 10:52
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.

Wrapped server using loadSchema returns null for aliased properties
2 participants