Created
November 14, 2018 14:35
-
-
Save apostopher/92e3c0f8c910ca0e6ad00c884e3c8c08 to your computer and use it in GitHub Desktop.
API server using graphql-yoga
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 { 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