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
const jwt = require('jsonwebtoken') | |
function getUserId(ctx) { | |
let authorization = ctx.request ? ctx.request.get('authorization') : null | |
// Get from subscription connection context | |
if (!authorization) { | |
authorization = ctx.connection ? ctx.connection.context.authorization : null | |
} |
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 { createHttpLink } from 'apollo-link-http' | |
import { ApolloLink, split, concat } from 'apollo-link' | |
import { ApolloClient } from 'apollo-client' | |
import { WebSocketLink } from 'apollo-link-ws' | |
import { getMainDefinition } from 'apollo-utilities' | |
import { InMemoryCache } from 'apollo-cache-inmemory' | |
import { onError } from 'apollo-link-error' | |
import { withClientState } from 'apollo-link-state' | |
import env from '../env.json' |
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
const { GraphQLServer } = require('graphql-yoga') | |
const { Prisma } = require('prisma-binding') | |
const resolvers = require('./resolvers') | |
const server = new GraphQLServer({ | |
typeDefs: 'src/schema.graphql', | |
resolvers, | |
context: req => ({ | |
...req, | |
db: new Prisma({ |