-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Hi!
We are developing a next generation journey planner platform and expose our data through GraphQL APIs. We use OpenTripPlanner as our backend, into which we have implemented a GraphQL API using graphql-java.
Now, we would like to impose some limits to how our public API can be used. For example, it would be nice to be able to say that each query may take no longer than a set time, e.g. two seconds. It's quite possible that our 3rd party API users can accidentally ask for too much information, and that would degrade the quality of service for the other users. OTP also does not at its current state survive from out of memory situations, and the way the GraphQL API is implemented does not contain any other resource guards either.
After investigating the situation, I think one way to implement this would be to have the ExecutionContext contain information about the time when the query resolution began, and when spawning new (parallel) futures, i.e. resolving fields, you could check to see if the time limit was exceeded and stop there.
Have you had any thoughts about implementing such querying limitations? And / or do you have interest in developing them? Maybe we can also fit an implementation into our next sprint. Do you think it would be a useful feature for other users as well? Do you have other ideas about this?
Here is some more information, our project is completely open source & open data.
- Here our running "alpha" SPA application http://matka.hsl.fi/
- Source code for the SPA https://github.com/HSLdevcom/digitransit-ui
- And here is our fork of the OpenTripPlanner https://github.com/HSLdevcom/OpenTripPlanner
Thanks!