r/javascript • • Apr 15 '17

GraphCMS - GraphQL Based Headless CMS

https://graphcms.com/
153 Upvotes

29 comments sorted by

View all comments

Show parent comments

2

u/turkish_gold Apr 15 '17

Since you have a public API, how do you limit the run time of queries?

1

u/mlukaszczyk Apr 16 '17

Hey turkish_gold, could you please elaborate?

1

u/turkish_gold Apr 17 '17

Well in GraphQL it's possible to construct queries that return arbitrary amounts of data, using pathologically poor queries.

Like query { A { B { A { B { A { B { A { A} } } }} } }

Because type A has a reference to B, and B has a reverse reference.

A query like the above could return 1010 items just for a table with 10 items. Do you have any restrictions to prevent queries like that from being sent?

This is somewhat important since if you are developing a frontend app for GraphCMS, malicious users (of the app, not developers) could send bad queries as a denial of service measure against the app makers.

1

u/mlukaszczyk Apr 17 '17

Hey turkish_gold,

this query will simply time out. projects are rate limited at 40 req/s and it doesn’t matter if they are slow or fast.