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 session = require("express-session"); | |
const { Prisma } = require("prisma-binding"); | |
const resolvers = require("./resolvers"); | |
const db = new Prisma({ | |
typeDefs: "src/generated/prisma.graphql", // the auto-generated GraphQL schema of the Prisma API | |
endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma API (value set in `.env`) | |
debug: true // log all GraphQL queries & mutations sent to the Prisma API | |
// secret: process.env.PRISMA_SECRET, // only needed if specified in `database/prisma.yml` (value set in `.env`) |
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 setTokenAfterware = new ApolloLink(async (operation, forward) => { | |
return forward(operation).map(async res => { | |
const context = operation.getContext(); | |
const { response: { headers } } = context; | |
const token = headers.get["x-token"]; | |
const refreshToken = headers.get["x-refresh-token"]; | |
if (token) { | |
await AsyncStorage.setItem("token", token); |