Please consider supporting Graphql Federation. This does not necessarily mean implementing all of the Apollo Federation Spec in this library, but just what would be necessary for someone implementing Apollo Federation to use this library for that purpose.
https://www.apollographql.com/docs/apollo-server/federation/federation-spec/
We use hundreds of microservices, and a monolithic GraphQL server becomes an unacceptable development bottleneck and single point of failure, so it becomes necessary to divide the graph's implemention into separate parts. We tried schema stitching, but would prefer federation for three reasons:
this seems outside the scope of this project.
How so? Supporting the parts of the Apollo spec to allow others to use this project to build federated graphql microservices seems pretty in scope.
Federation is an Apollo spec not a graphql spec. This library implements the graphql spec https://graphql.github.io/graphql-spec/June2018/ which has no mention of federation.
Actually I apologize. I realize you are just asking this library to support the additions not federation itself. I believe the additions should be in scope
No worries, I clarified my request. Sorry for not being more clear from the beginning.
You could implement federation in a separate library. See for example: https://github.com/0xR/graphql-transform-federation. It takes an existing schema and with some configuration it can add federation support. Note that that is a NodeJS implementation, but I'm sure it could be implemented in Go as well.
If you're ok with running NodeJS you can add federation support to your Go service by using graphql-transform-federation as a middleware service. It can take a remote schema as input as well.
@chris-cp
Is there interest in this library supporting this? I've read the federation spec a couple of times now and it seems at a high level this library would need to support:
_service query would need this library to either support printing the schema as this spec describes or exposing the AST of a schema created with graphql.NewSchema so that another library could handle printing out the SDL.
Stub types could probably already be implemented by another library, but again it would require we are able to read an AST in order to know what fields to implement a stub for. I wasn't able to find a way to get an AST from a schema created with graphql.NewSchema, but I might be overlooking it?
Entities again could probably be implemented in another library provided this library is able to expose its AST so that we can create a union type as described in the spec.
Directives should not need to be implemented as that appears to be entirely handled at the gateway level and not individual federated services.
It seems that this spec could be entirely implemented in another package as long as this package is able to expose its AST. If anyone has any thoughts or feedback I'm interested in hearing them. Also if @chris-cp is interested in supporting this but maybe does not have the time, then I would happy to take a shot and open a PR.
Anyone knows about any library to handle this?
gqlgen has supported it for some time.
Most helpful comment
@chris-cp
Is there interest in this library supporting this? I've read the federation spec a couple of times now and it seems at a high level this library would need to support:
_service query would need this library to either support printing the schema as this spec describes or exposing the AST of a schema created with
graphql.NewSchemaso that another library could handle printing out the SDL.Stub types could probably already be implemented by another library, but again it would require we are able to read an AST in order to know what fields to implement a stub for. I wasn't able to find a way to get an AST from a schema created with
graphql.NewSchema, but I might be overlooking it?Entities again could probably be implemented in another library provided this library is able to expose its AST so that we can create a union type as described in the spec.
Directives should not need to be implemented as that appears to be entirely handled at the gateway level and not individual federated services.
It seems that this spec could be entirely implemented in another package as long as this package is able to expose its AST. If anyone has any thoughts or feedback I'm interested in hearing them. Also if @chris-cp is interested in supporting this but maybe does not have the time, then I would happy to take a shot and open a PR.