Is your feature request related to a problem? Please describe.
For an ongoing project, I need to implement an Apollo Gateway for a project, with a federated GraphQL schema from several sources, including DatoCMS.
Apollo provides those features already, it just requires the different GraphQL schemas to implement the Federation specifications:
I tried implementing a Gateway with DatoCMS as one of the federated source, but I do not think DatoCMS schema currently implements those specifications (unless I am doing something wrong?)
Encountered error when loading content at https://graphql.datocms.com/: Cannot read property ‘sdl’ of undefined
Describe the solution you’d like
Is it possible for DatoCMS to consider implementing those?
The migration from ApolloSever is pretty straightforward (not sure which tech is DatoCMS using under the hood but the @apollo/federation package can probably help, directly or as an example?)
https://www.apollographql.com/docs/apollo-server/federation/implementing/
Describe alternatives you’ve considered
An alternative would be to use DatoCMS as a Datasource for ApolloServer, but I am afraid to loose all the benefits of GraphQL by doing that?
https://spectrum.chat/apollo/apollo-federation/remote-schemas-and-apollo-federation~74f89ac9-2623-4c51-bb87-8880a140fc27
Additional context
This is the local Gateway implementation I have tried (using node.js):
const { ApolloServer } = require('apollo-server');
const { ApolloGateway } = require('@apollo/gateway');
const gateway = new ApolloGateway({
serviceList: [
{ name: 'my-service-1', url: 'http://localhost:4001' },
{ name: 'my-service-2', url: 'http://localhost:4002' },
{ name: 'content', url: 'https://graphql.datocms.com/' }
],
buildService({ name, url }) {
return new RemoteGraphQLDataSource({
url,
willSendRequest({ request, context }) {
switch (name) {
case 'content':
// Authenticate requests to DatoCMS
request.http.headers.set('authorization', process.env.DATOCMS_API_KEY);
break;
}
},
});
},
debug: process.env.NODE_ENV !== 'production'
});
(async () => {
const { schema, executor } = await gateway.load();
const server = new ApolloServer({ schema, executor });
server.listen().then({ url }) => {
console.log(`🚀 ApolloGateway ready at ${url}`);
});
})();