apollo-server#makeExecutableSchema TypeScript Examples
The following examples show how to use
apollo-server#makeExecutableSchema.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: execution.ts From genql with MIT License | 6 votes |
async function server({ resolvers, port = PORT }) {
try {
const typeDefs = fs
.readFileSync(path.join(__dirname, '..', 'schema.graphql'))
.toString()
const server = new ApolloServer({
schema: makeExecutableSchema({
typeDefs,
resolvers,
resolverValidationOptions: {
requireResolversForResolveType: false,
},
}),
subscriptions: {
onConnect: async (connectionParams, webSocket, context) => {
console.log(
`Subscription client connected using Apollo server's built-in SubscriptionServer.`,
)
},
onDisconnect: async (webSocket, context) => {
console.log(`Subscription client disconnected.`)
},
},
})
// The `listen` method launches a web server.
await server.listen(port).then(({ url, subscriptionsUrl }) => {
console.log(`? Server ready at ${url} and ${subscriptionsUrl}`)
})
return () => server.stop()
} catch (e) {
console.error('server had an error: ' + e)
return () => null
}
}