This tutorial requires that you have a knowledge of GraphQL queries, mutation and context.
yarn add bcrypt jsonwebtoken node-fetch nodemailer graphql-middleware graphql-shield google-auth-library
type User {
id: ID! @id
name: String!
email: String! @unique
password: String
isAdmin: Boolean @default(value: false)
resetPasswordToken: String @default(value: "")
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
We have to create a context type for it
import { Prisma } from "./generated/prisma-client";
export interface Context {
prisma: Prisma;
request: {
request: {
headers: {
authorization: string;
};
};
connection: {
context: {
Authorization: string;
};
};
};
}
After defining the context type set global context to prisma and request so we can use prisma methods and request object for getting authorization token.
#web-development #javascript #programming #graphql #prisma