Skip to content

Instantly share code, notes, and snippets.

@DWboutin
Created November 8, 2022 15:28
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 DWboutin/aba87ace009eafc83161c44fe446163a to your computer and use it in GitHub Desktop.
Save DWboutin/aba87ace009eafc83161c44fe446163a to your computer and use it in GitHub Desktop.
Apollo-server base file for tutorial
import { ApolloServer } from '@apollo/server'
import { startStandaloneServer } from '@apollo/server/standalone'
// The GraphQL schema
const typeDefs = `#graphql
type Query {
hello: String
}
`
// A map of functions which return data for the schema.
const resolvers = {
Query: {
hello: () => 'world',
},
}
const server = new ApolloServer({
typeDefs,
resolvers,
})
const startServer = async () => {
const { url } = await startStandaloneServer(server)
console.log(`🚀 Server ready at ${url}`)
}
startServer()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment