We’re starting to define relationships in our federated graph and I’ve been thinking a lot about data validation around mutations.
Let’s say we have a Products subgraph and a Reviews subgraph. When we create a mutation to add a review to a product… how do we validate that the product exists before adding the review? These subgraphs are completely separate microservices with their own data stores. Obviously we don’t want to grant access to the Reviews service to query Products data directly.
There’s got to be a smarter way to handle this than firing a separate GQL query from the Reviews subgraph to the Products subgraph, right? We’re currently not allowing subgraphs to query each other so that would mean actually going back through the gateway. I’ve also just straight up considered skipping validation altogether, which maybe for this instance isn’t that big of a deal but down the road we will absolutely want to validate that the other end of the relationship exists before creating entities.
How are folks doing this elegantly?