Skip to content

Instantly share code, notes, and snippets.

@apostopher
Created November 14, 2018 14:35
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 apostopher/92e3c0f8c910ca0e6ad00c884e3c8c08 to your computer and use it in GitHub Desktop.
Save apostopher/92e3c0f8c910ca0e6ad00c884e3c8c08 to your computer and use it in GitHub Desktop.
API server using graphql-yoga
import { GraphQLServer } from 'graphql-yoga'
// Import the resolvers
import resolvers from 'src/resolvers'
// Import our custom directive
import isAuthenticated from 'src/isAuthenticated'
const server = new GraphQLServer({
typeDefs: `${__dirname}/schema.graphql`,
resolvers,
schemaDirectives: { isAuthenticated }
context: req => ({ req }),
})
server.start(() => console.log(`GraphQL server is running on port 4000`))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment