Hi everyone! I’m trying to figure out if it’s possible to share type definitions between backend services, but not getting anywhere.
Basically, my company has our graphql services split over two different backends, which each define their own queries, mutations, types, etc. We’re trying to consolidate all our logic into a single backend, but, because that takes a lot of time, we’re in a weird state where some of the data lives in backend 1 while some of the mutations are defined in backend 2 (which calls backend 1). So we make a query to get a list of data from backend 1, but update some of that data via a mutation in backend 2. Backend 2 then makes a graphql request to backend 1 and receives the updated data.
To make the apollo caching on the client happy, I want the mutation in Backend 2 to pass that updated data back to the client, using the data type defined in Backend 1. That way, the frontend has its list of MyDataObjects in the cache, and, when Backend 2 sends back an updated MyDataObject(id=123), the frontend cache can be updated. But I can’t figure out how to write my schemas in Backend 2 in such a way that the mutation can send back the data it receives from Backend 1. Schema loading looks like it should support this, but I haven’t been able to make it work. I want something like
type Mutation {
"update the data in other backend"
updateMyData(input: ID!): MyDataObject! (the type defined in the other backend)
}
How do I write a schema definition such that I can define the return type as a type defined in a different service?
Thanks!