-
Hello! Firstly, thanks for all the work you guys do making these tools. We're currently planning our approach to support subscriptions w/ our existing Apollo Federation graph (I'm sure you are all familiar w/ the issues surrounding that). We'd like to define the subscriptions in the same services that currently implement our queries and mutations. My question is, should we stitch the federated gateway w/ the subscription types + resolvers from the individual services, or should we just completely replace the Apollo Gateway w/ a schema stitched gateway? We have ~10 federating services, is it as easy as swapping out the gateway and using @gmac's federation-to-stitching-sdl tool? Or would we have to write lots of custom logic, e.g. individual resolver logic for each of our federated types? Appreciate any insight you have into this, thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hi @dobrynin! Good question. There’s lots of ways you could approach this. The main constraint here is that subscription types need a direct link to the gateway so that we can proxy service > gateway > client. Otherwise, everything else can do what you want. A naive approach would be to take the Federation gateway as it exists and stitch it together with the subscription types filtered out of their respective subservice schemas. This leaves a lot of what you already have in tact, but is really messy and adds a middle proxy layer of stitching > federation > subservice. The simpler approach is almost certainly just to pull out the federation gateway and stitch the subservices directly. Then the complete subservice schemas, subscription types and all, are direct members of the gateway schema and less prone to indirection errors and inefficiencies. How you stitch the subservices is up to you. That automatic SDL transformer I wrote is a quick start, although buyer beware that it hasn’t been battle tested against the plethora of possible federation edge cases (please report back on your experiences!) While the SDL transformer would be a good start, I would recommend eventually phasing out “buildFederatedSchema” tooling one service at a time if you commit to this direction. Stitching doesn’t use all of federation’s ghost field additions (external), so the subservice is needlessly complex as a GraphQL resource. Also, federation makes heavy use of computed field patterns (requires) to do fairly mundane object associations. If you’re phasing out federation anyway, you might as well invert these situations into simpler merged foreign key types that don’t involve passing dependencies between services. |
Beta Was this translation helpful? Give feedback.
Hi @dobrynin!
Good question. There’s lots of ways you could approach this. The main constraint here is that subscription types need a direct link to the gateway so that we can proxy service > gateway > client. Otherwise, everything else can do what you want.
A naive approach would be to take the Federation gateway as it exists and stitch it together with the subscription types filtered out of their respective subservice schemas. This leaves a lot of what you already have in tact, but is really messy and adds a middle proxy layer of stitching > federation > subservice.
The simpler approach is almost certainly just to pull out the federation gateway and stitch the subservices directly. Then…