Created
June 7, 2022 08:50
-
-
Save fetimo/7d33b6fab8f4b016f442ea8438e942a5 to your computer and use it in GitHub Desktop.
Basic Apollo gateway
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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