Re:You Shouldn’t Use GraphQL
by ashleyn on Friday November 12, 2021 @04:35PM
(#29204814)
Point 1, exposing a potential denial of service attack via expensive queries, was always a point of contention I had with GraphQL. I'd love to explore using GraphQL in a project but security is typically a high priority. What is the generally accepted way of preventing denial of service attacks using oversized GraphQL queries?
[ Parent
| on HN ]
Re:You Shouldn’t Use GraphQL
by michaelghayes on Saturday November 13, 2021 @01:56AM
(#29207983)
one popular option is to have a query whitelist, with arbitrary queries allowed either through special permissions, or just in development. setting up CI steps to auto-publish any queries used by your apps is usually pretty straight forward. this obviously only works for non-public APIs.
Another common patter is to have a way to calculate query complexity, where each field had some cost, and some multiplier for list fields so you can calculate an approximate complexity before executing a query
Re:You Shouldn’t Use GraphQL
by acidbaseextract on Friday November 12, 2021 @05:03PM
(#29205064)
FTA, though the misspellings are frustrating:
In a GraphQL API, tools such as Dataloader allow you to batch and cache database calls. But in some cases, even this [isn't] enough and the only solution is to block queries by calculating a maximum execution cost or query [depth]. And any of these solutions will depend on the library you’re using.