1

Application is built using graphql (hasura), postgres and nodejs. The app gets deployed to each clients separately having different DB and so on. Currently, we need to make connection to different clients, so they can access each other DB.

One architecture which makes sense is mesh where multiple clients can connect across each other. So there are basically 3 things which needs to be implemented: Query, Mutation and Subscription.

I am trying to merge the results of the query fetching from all the clients when the request is triggered. This works but, is there any good way so I don't need to rewrite each and every custom query and mutation in hasura to handle multiple requests combing all the results. Same approach for mutation but redirecting the request to particular client.

Maybe a good way to do in Database itself combining multi DB? Or is there any good high level design which solves this problem?

phantom
  • 1,014
  • 1
  • 7
  • 15
  • [federation](https://www.apollographql.com/docs/federation/#:~:text=Apollo%20Federation%20is%20a%20powerful,Supergraph) – Michel Floyd Apr 18 '23 at 17:20
  • @MichelFloyd Multiple application have same DB. Does federation support for that too? – phantom Apr 19 '23 at 06:24
  • Hey @phantom have you looked at hasura's remote schema feature ? ref - https://hasura.io/docs/latest/remote-schemas/overview/ – Meet Zaveri Apr 19 '23 at 15:58
  • @phantom - federation supports the creation of a supergraph from multiple independent schemas. If one of those subgraphs is tied to a single db and multiple applications talk to that subgraph that's fine. The opposite is also fine e.g. one app talking to to multiple schemas via federation. – Michel Floyd Apr 19 '23 at 16:43
  • @MichelFloyd Actually there is one system which can have multiple replicas. And from any system we need to communicate with another system. So, in a system can we merge another system (same db but data is different) using apollo federation? – phantom Apr 20 '23 at 15:13
  • @MeetZaveri We can add remote schema, but we cannot merge using remote schema right? – phantom Apr 20 '23 at 15:14
  • @phantom When you add them to single hasura instance, you automatically get stitched schema together under single GraphQL API. – Meet Zaveri Apr 24 '23 at 08:18

1 Answers1

0

There are a three different approaches for integrating multiple systems:

  1. Hasura Remote Schemas that allows you to merge multiple GraphQL schemas into one unified schema: https://hasura.io/docs/latest/remote-schemas/overview/

  2. GraphQL Federation is an architecture pattern that allows you to build a unified API across multiple services. Apollo Federation, for example, is a popular implementation of this pattern.

  3. Connect multiple PostgreSQL databases to a single Hasura instance.

Kaspar L. Palgi
  • 1,332
  • 10
  • 22