phillythompson
phillythompson

Reputation: 111

Multiple GraphQL "hops" in end-to-end flow?

I am working on an enterprise-level system and am trying to understand if my idea is super inefficient.

Our company is looking to use GraphQL, and we want to use it as a way to assist the front-end client in retrieving data, but also as a data abstraction over our raw data. What I mean is:

enter image description here

I know the question might arise: "Why don't you have GraphQL over the domain services, and GraphQL over the data, but then federate those into a gateway and have clients pull from there!" But one of the tenants we are sticking to at our company is there must be an abstraction over our data. So, we either abstract that data via a REST API (which we do now), or we have GraphQL over the data and act as the abstraction.

So given that "data abstraction" requirement, I want to understand if there are any issues with the two "hops"/instances of GraphQL in the end-to-end flow?

Upvotes: 0

Views: 114

Answers (1)

Mike
Mike

Reputation: 796

This is a common pattern. We used this for our backend services, which received graphql on the domain layer and then used prisma for the data layer.

I have two recommendations from our experience.

  • Try, as best as possible, to auto-generate both your resolvers and your data API using a language, specific tool.
  • Do testing against the domain layer to make sure that nothing from the data layer slips through. It will be tempting to do simple "pass through" requests as the two schemas will often start off synchronized, and you may wind up accidentally passing through data you don't want going to the client.

(Shameless plug!) For the second one, Meeshkan does this sort of testing in an automated fashion, and there are plenty of testing frameworks you can use to execute hand-written tests as well (ie cucumber.

Upvotes: 1

Related Questions