Simplifies app development and accelerates developer velocity.
I had the opportunity to speak with Peggy Rayzis, Engineering Manager at Apollo GraphQL following the virtual GraphQL Worldwide Summit to learn about the current and future state of GraphQL.
GraphQL is a new layer in the stack between application clients and services like REST APIs and databases. It simplifies development by combining APIs, databases, and microservices into a single data graph that can be queried. It also enables flexible connection with other data sources which has become more important with the proliferation of databases and clients that requires pulling data from different sources. GraphQL normalizes the process to reduce how much code needs to be written to pull the necessary data.
REST APIs are not a good fit for modern apps because they require a lot of hard-to-manage data fetching code. GraphQL enables developers to declare their data requirements to get the right data to the right place with strong end-to-end typing that prevents bugs while increasing productivity.
By having all of the data managed in one place, it’s easy to browse data, join data across multiple sources, and get results in the desired format on any platform.
GraphQL fits with microservices architectures and modern UI frameworks like React. It serves as an abstraction layer that decouples services and apps so that each can be developed independently in any language and on any platform.
Adding a new graph layer to the stack lets the team build new features and bring the app to new platforms in a timely manner. App developers can delete thousands of lines of boilerplate code, move quickly without waiting on back-end teams, and keep features consistent between web and mobile platforms.
Peggy recommends product developers start small with one endpoint and a small schema to connect the client to the graph. Once you get up and running, you are able to see the bigger picture and productivity gains. Use federation to enable many teams to contribute to the graph. Avoid the temptation for each team to create their own graph since this defeats a major benefit of GraphQL and hinders collaboration.
Use cases are broad with developers in e-commerce, financial services, healthcare - any company with multiple data sources and clients since the graph data layer reduces the amount of code needed to write for different apps, operating systems, and IoT devices.
Challenges Peggy has seen when scaling GraphQL across multiple teams is that different graphs start popping up. Teams need to use federation to bring all of the data together in a single graph so they have a single source of truth for data.
Peggy, a data engineer herself, recommends developers start small, don’t convert everything at once. Don’t replicate every REST API in the first schema. Only add the things your users are using and need. Keep the schema thin and only add what’s needed as it is needed. You’ll begin to see the magic after connecting one client to your first schema.