If we have a MongoDB database and app service for it, utilizing the Atlas GraphQL API, it autogenerates the GraphQL schema itself and you cannot modify as far as I can tell.
I want to know if I can use this as a subgraph in Apollo Federation. The reason I am unsure if it will work, is Apollo Federation appears to require metadata & directives to specify to the supergraph certain things (ie. the @keys directive on a type to say which fields are the Ids defined in both subgraphs). Because of stuff like this, and not seeing a way to add this to the GraphQL schema within the app service / Atlas GraphQL API, I don’t believe it would work.
I realize that I could create my own service to handle GraphQL requests with Apollo Server or something similar, and hook it up to MongoDB as the datasource with something like Mongoose and therefore use it with Apollo Federation, but I am wondering if it is possible to use the Atlas GraphQL API as a subgraph for Apollo Federation.
That’s a really good question because I also just finished viewing the youtube video you mentioned, and I was very disappointed : At the beginning of the video, she talked about how it is really quick to create its own GraphQL API based on its MongoDB collections, but then, the guy who presents the federation recreates all those APIs from scratch.
So where is AppService GraphQL usefull here ???
Any update on this? Have you tried to implement it?
As alternative i was thinking to use the function trigger from atlas service to control the input data or requesting external API (to retrieve extra information for example) before updating the database, but I dont know how flexible it is and if it will be easy to maintain. Any thought about it?
That’s what I did finally. I created my own federation with NestJS and Apollo server. I abandoned the idea of using Appservice to create my graphql apis and use them inside a federation. It’s just a shame because the GQL schema generation is really awesome and really helpful to have a complete CRUD graphQL API on your data.
I think i will still use the appService and use Apollo Server as a graphql proxy that will do graphql query to the AppService and check the input data. I dont know if it is a good idea but AppService has nice features that can be helpful later (triggers/eventBridge on database update - authentication…) and add a layer of abstraction on the database.