n1ru4l / envelop

Envelop is a lightweight library allowing developers to easily develop, share, collaborate and extend their GraphQL execution layer. Envelop is the missing GraphQL plugin system.
https://envelop.dev
MIT License
787 stars 127 forks source link

add `usePrunedSchema` plugin #2157

Open EmrysMyrddin opened 8 months ago

EmrysMyrddin commented 8 months ago

Description

Adds a plugin to automatically clean up the schema by applying pruneSchema from @graphql-tools/utils.

Type of change

changeset-bot[bot] commented 8 months ago

⚠️ No Changeset found

Latest commit: 8cec5a2583787eaf12af331bac14799db48f4ef1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

github-actions[bot] commented 8 months ago
### 💻 Website Preview The latest changes are available as preview in: [https://57d381bd.envelop.pages.dev](https://57d381bd.envelop.pages.dev)
theguild-bot commented 8 months ago

✅ Benchmark Results

     ✓ no_errors
     ✓ expected_result

     checks.............................................: 100.00% ✓ 839606     ✗ 0     
     data_received......................................: 3.2 GB  27 MB/s
     data_sent..........................................: 183 MB  1.5 MB/s
     envelop_total......................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     event_loop_lag.....................................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-and-no-internal-tracing }...: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-cache-jit }.......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:envelop-just-cache }......................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     ✓ { mode:graphql-js }..............................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     http_req_blocked...................................: avg=1.94µs  min=701ns    med=1.7µs   max=5.3ms   p(90)=2.3µs   p(95)=2.6µs  
     http_req_connecting................................: avg=23ns    min=0s       med=0s      max=1.27ms  p(90)=0s      p(95)=0s     
     http_req_duration..................................: avg=2.56ms  min=147.45µs med=2.21ms  max=80.74ms p(90)=4.64ms  p(95)=5.18ms 
       { expected_response:true }.......................: avg=2.56ms  min=147.45µs med=2.21ms  max=80.74ms p(90)=4.64ms  p(95)=5.18ms 
     ✓ { mode:envelop-cache-and-no-internal-tracing }...: avg=2.71ms  min=366.95µs med=2.35ms  max=17.8ms  p(90)=4.64ms  p(95)=5.04ms 
     ✓ { mode:envelop-cache-jit }.......................: avg=1.52ms  min=147.45µs med=1.19ms  max=15.24ms p(90)=2.46ms  p(95)=2.64ms 
     ✓ { mode:envelop-just-cache }......................: avg=2.72ms  min=398.62µs med=2.34ms  max=36.36ms p(90)=4.64ms  p(95)=5.1ms  
     ✓ { mode:graphql-js }..............................: avg=5.07ms  min=540.84µs med=4.28ms  max=80.74ms p(90)=8.52ms  p(95)=9.3ms  
     http_req_failed....................................: 0.00%   ✓ 0          ✗ 419803
     http_req_receiving.................................: avg=34.84µs min=11.46µs  med=27.67µs max=14.83ms p(90)=41.99µs p(95)=46.51µs
     http_req_sending...................................: avg=12.14µs min=4.68µs   med=9.85µs  max=10.06ms p(90)=14.21µs p(95)=18.33µs
     http_req_tls_handshaking...........................: avg=0s      min=0s       med=0s      max=0s      p(90)=0s      p(95)=0s     
     http_req_waiting...................................: avg=2.51ms  min=121.4µs  med=2.16ms  max=80.64ms p(90)=4.59ms  p(95)=5.12ms 
     http_reqs..........................................: 419803  3498.17913/s
     iteration_duration.................................: avg=2.85ms  min=359.26µs med=2.47ms  max=81.32ms p(90)=4.94ms  p(95)=5.54ms 
     iterations.........................................: 419803  3498.17913/s
     vus................................................: 10      min=10       max=10  
     vus_max............................................: 20      min=20       max=20  
EmrysMyrddin commented 8 months ago

This is probably for when you are not fully in control of the schema you are exposing, like federating multiple schemas from other teams in your company :-)

But If you think this is not useful I can close it. I'm not that much convinced of the utility of this, it should perhaps better be applied on schema loading. But this has the good aspect of being very simple to add to an existing setup. Just put the plugin and the schema is cleaned up.