apollographql / router

A configurable, high-performance routing runtime for Apollo Federation 🚀
https://www.apollographql.com/docs/router/
Other
813 stars 271 forks source link

Limit the amount of GraphQL validation errors returned in the response #6187

Closed goto-bus-stop closed 1 week ago

goto-bus-stop commented 3 weeks ago

A small proposal.

It's possible to craft relatively small queries (within a few dozen KB) that produce tens of thousands of validations errors. The router then needs to spend a bunch of time formatting several megabytes of JSON in response. That's a waste of time.

By limiting the amount of errors we limit the response size and the time spent formatting the response to those queries.

I only applied it to GraphQL parsing and validation errors here. Perhaps it should be a general limit in the router. But for parsing and validation errors I think it's reasonable to silently drop further errors--I'm not sure it's appropriate for every other kind of error.

svc-apollo-docs commented 3 weeks ago

✅ Docs Preview Ready

No new or changed pages found.

github-actions[bot] commented 3 weeks ago

@goto-bus-stop, please consider creating a changeset entry in /.changesets/. These instructions describe the process and tooling.

router-perf[bot] commented 3 weeks ago

CI performance tests

yanns commented 1 week ago

This is a good idea. We did that in the sangria library as well for example: