Skip to content

Instantly share code, notes, and snippets.

@fetimo
Created June 7, 2022 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fetimo/7d33b6fab8f4b016f442ea8438e942a5 to your computer and use it in GitHub Desktop.
Save fetimo/7d33b6fab8f4b016f442ea8438e942a5 to your computer and use it in GitHub Desktop.
Basic Apollo gateway
import { ApolloServer } from 'apollo-server-micro';
import { ApolloGateway, IntrospectAndCompose } from '@apollo/gateway';
const apolloServer = new ApolloServer({
gateway: new ApolloGateway({
supergraphSdl: new IntrospectAndCompose({
subgraphs: [
{ name: 'saleor', url: process.env.SALEOR_GRAPHQL },
],
}),
}),
subscriptions: false,
});
const startServer = apolloServer.start();
const gateway = async (req, res) => {
await startServer;
return apolloServer.createHandler({
path: '/api/gateway',
})(req, res);
};
export default gateway;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment