PolyAPI  >  Learn More  >  Blog

Darko’s Thoughts: GraphQL and REST APIs – What Does the Future Hold?

Data Servers

A common question arises in the ever-evolving world of APIs: What’s the future of GraphQL (GQL) compared to REST APIs? Many enterprises consider GraphQL a replacement for REST, while others believe it’s a complementary layer. Some dismiss it as unnecessary. My stance is that these technologies will co-exist, with each one suited for different project needs. I believe that most companies will eventually employ both and that GraphQL is not well suited to replace orchestration middleware layers. Importantly, it’s not a subject to be dogmatic about. Here’s a deeper dive into why.

The Specialties of Both Technologies

REST APIs have stood the test of time, particularly for CRUD (Create, Read, Update, Delete) applications and for working with standardized objects. They are the backbone of typical web and mobile applications, where simplicity and consistency are paramount. Their straightforward nature makes them ideal for these scenarios. Their usage will only continue to grow.

On the other hand, GraphQL shines when it comes to more complex use cases, such as data-heavy dashboards and data analysis tools. With its ability to query multiple resources in a single request and precisely fetch only the data required, it streamlines the data retrieval process. GraphQL is an excellent choice for applications where users interact with large datasets and need flexibility in the types of data they query.

Common Anti-Patterns to Avoid

As with any technology, some pitfalls can undermine the effectiveness of APIs. One such anti-pattern is using query parameters in REST APIs to support custom query languages—something that GraphQL was designed to address. While this approach may have “worked” before GraphQL existed, it became outdated and inefficient once GraphQL was in play.

Another common mistake is placing GraphQL on top of existing REST APIs as a unified layer. While this might seem like a convenient solution, it introduces a steep learning curve for client developers, additional latency, and an operational complexity that should be avoided. Instead of trying to force-fit GraphQL into a REST-based architecture, it’s crucial to evaluate whether GraphQL truly adds value in each specific case.

Additionally, some organizations may implement GraphQL in ways that introduce unnecessary complexity, such as failing to clearly define the boundaries between GraphQL’s role in querying data and the orchestration layer that handles business logic. It’s crucial to understand where GraphQL ends and where the orchestration middleware begins to maintain a clean and efficient architecture. The critical point here is that the middleware must be accessible to both client and backend developers to ensure success, while the GraphQL layer is primarily queryable by client developers and implementable by backend developers. This distinction helps prevent confusion and ensures that each layer performs its intended function.

The Future of GraphQL SDKs

When it comes to SDKs for GraphQL, things are looking promising. Currently, the SDK generation for GraphQL is well done, enabling developers to get started with queries and mutations quickly. However, there’s still a gap in generating standard functions bound to specific queries that could help beginners or those needing to get common data out quickly. I believe this will become automatic and data-driven, where the most popular use cases automagically become generated functions for others.

Take a hotel’s nightly audit report, for example. It shouldn’t require writing a complex query or copying code from a blog post. Instead, pre-built functions in the SDK should handle these basics, especially for users who aren’t with GraphQL.

SDKs should also transcend the boundaries of individual GraphQL providers, unifying with REST and SOAP APIs to create a seamless experience. By avoiding the creation of separate islands for each technology, developers can save time and reduce the learning curve.

The Future of GraphQL Documentation

A significant advantage of a well-designed REST API is that you can predict its behavior based on principles. Documentation validates these principles and provides the exact strings needed for implementation. However, GraphQL is inherently more complex due to its flexibility and the dynamic nature of the queries it supports.

Its introspection endpoint is the key to improving the developer experience with GraphQL. This allows developers to explore the GraphQL schema, providing vital information about available queries, mutations, and types. The next big leap will be using AI to parse the introspection endpoint and generate queries automatically, allowing developers to interact with GraphQL APIs directly without needing deep expertise. This vision would simplify API interactions and make documentation a tool that drives productivity.

Embracing a Hybrid Approach

Looking ahead, I believe GraphQL and REST will co-exist, each finding its place within enterprise architectures. In most cases, companies will need both technologies to meet the unique demands of different use cases. For example, REST may be used for simpler, CRUD-based interactions, while GraphQL can be employed for more complex data fetching and analysis.

The future of GraphQL SDKs and documentation is bright, with AI and introspection offering exciting possibilities for automating queries and simplifying interactions. By integrating GraphQL with existing REST and SOAP APIs and ensuring that documentation and SDKs are unified across platforms, we can create a more efficient and developer-friendly experience.

If this vision of developer-focused API documentation resonates with you, or if you’re interested in how we’re transforming the documentation experience at PolyAPI, don’t hesitate to connect with us. Let’s make API documentation a tool that drives productivity, not a roadblock.

Contact us at hello@polyapi.io to learn more.

Share this Article: