GraphQL - what is it and why you need it

GraphQL - what is it and why you need it

This presentation was held at JavaBin's summer meetup at Teknologihuset in Oslo.

Parts of the Q/A session:
Q: How do you deal with adding/removing fields in GraphQL?
A: Adding is simple. Removing is not. Usual practice is to mark a field as deprecated and then remove it later on

Q: What are some challenges with performances?
A: No limits on query depths might affect performance, but you can cope with this by planning your database queries properly. Instrumentation that lets you know about slow queries (logging queries slower than a certain threshold to your ELK stack for instance) .

Q: Is there any library that lets you map your database model to GraphQL queries?
A: Not a library, but there is something called Prisma. See: for a tool that autogenerates a GraphQL server based on your database model.

Q: What about caching? GraphQL is all POST. How do you handle caching?
A: Two-fold answer: Caching in the client is handled by the client of your choice. Apollo client has a read-through cache in it that will cache a lot of your data (can be turned off if necessary). Caching on the server can be implemented in your service/module layer.

Q: What is the most important tip you can give to developers that are new to GraphQL?
A: Focus on delivering value to your customer(s). GraphQL may potentially *not* be the answer to your pain points, so keep an eye out for that. However, all things considered, the most important part of implementing a GraphQL server is being really aware of the business domain and creating a model that maps more or less 1-1 to the business domain.

Q: How do you avoid breaking schemas between frontend and backend?
A: Feel free to pick your own solution. In my team, we currently don't have anything specific beyond code reviews. However, you can run linters that expose any schema breakage.


Arnab Datta

June 12, 2019