Docs
Launch GraphOS Studio

GraphQL as an abstraction layer

Use GraphQL as an abstraction between service consumers and backend services

architecture-patterns

One of the advantages of using is that it provides an abstraction between service consumers and the teams maintaining the backend services.

In a backend-for-frontend (BFF) architecture, each BFF connects to any number of backend services. As you add new BFFs for each application, the number of connections proliferates, and changes to any backend services have major implications.

🖥️ App
📱 App
📱 App
🖥️ App
🖥️ App
BFF
BFF
BFF
BFF
BFF
REST Service 1
REST Service 2
REST Service 3
REST Service 4
REST Service 5
SOAP Service 1
SOAP Service 2
SOAP Service 3
SOAP Service 4
SOAP Service 5
gRPC Service 1
gRPC Service 2
gRPC Service 3
gRPC Service 4
gRPC Service 5

Service migration example

Suppose a company has an architecture with ten applications, each with its own BFF. The company is migrating one of many backend APIs to a different technology. As a result of the BFFs owning data orchestration, the organization must update ten different BFFs.

To avoid breaking changes, clients must:

  • be aware of what is happening during those change,
  • track timelines,
  • and track changes to names.

🖥️ App
📱 App
📱 App
🖥️ App
🖥️ App
🖥️ App
📱 App
📱 App
🖥️ App
🖥️ App
BFF
BFF
BFF
BFF
BFF
BFF
BFF
BFF
BFF
BFF
❌ Old Service ❌
✨ New Service ✨

If the company used GraphQL as an abstraction layer, the consumers wouldn't need to know about this change because the organization has abstracted backend APIs behind a graph schema. The only change needed is at the GraphQL layer.

🖥️ App
📱 App
📱 App
🖥️ App
🖥️ App
🖥️ App
📱 App
📱 App
🖥️ App
🖥️ App
❌ Old Service ❌
✨ New Service ✨
✅ GraphQL ✅

As a company grows, this could eliminate hundreds of updates, deployments, and dependencies due to the reduced impact of changes to backend services.

Conclusion

GraphQL is a powerful tool for abstracting away the complexities of backend services from frontend consumers. It can shield consumers from major changes to those services while reducing the impact of those changes. Ultimately, it provides choice and control to consumers without negatively impacting backend services.

Further reading

Next
Home
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company