-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Prabhat Pal
committed
Feb 2, 2021
1 parent
9836736
commit 9fd3e01
Showing
12 changed files
with
543 additions
and
24 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import "reflect-metadata"; | ||
import { ApolloServer } from "apollo-server-micro"; | ||
import { Context } from "src/schema/context"; | ||
import { NextApiRequest } from "next"; | ||
import { loadIdToken } from "src/auth/firebaseAdmin"; | ||
import { prisma } from "src/prisma"; | ||
import { schema } from "src/schema"; | ||
|
||
const server = new ApolloServer({ | ||
schema, | ||
context: async ({ req }: { req: NextApiRequest }): Promise<Context> => { | ||
const uid = await loadIdToken(req); | ||
|
||
return { | ||
uid, | ||
prisma, | ||
}; | ||
}, | ||
}); | ||
|
||
const handler = server.createHandler({ path: "/api/graphql" }); | ||
|
||
export const config = { | ||
api: { | ||
bodyParser: false, | ||
}, | ||
}; | ||
|
||
export default handler; |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# ----------------------------------------------- | ||
# !!! THIS FILE WAS GENERATED BY TYPE-GRAPHQL !!! | ||
# !!! DO NOT MODIFY THIS FILE BY YOURSELF !!! | ||
# ----------------------------------------------- | ||
|
||
type Query { | ||
hello: String! | ||
} |
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { AuthChecker } from "type-graphql"; | ||
import { Context } from "./context"; | ||
|
||
export const authChecker: AuthChecker<Context> = ({ context }) => { | ||
const { uid } = context; | ||
return !!uid; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PrismaClient } from "../prisma"; | ||
|
||
export interface Context { | ||
uid: string | null; | ||
prisma: PrismaClient; | ||
} | ||
|
||
export interface AuthorizedContext extends Context { | ||
uid: string; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { buildSchemaSync, Resolver, Query } from "type-graphql"; | ||
import { authChecker } from "./authChecker"; | ||
|
||
@Resolver() | ||
class DummyResolver { | ||
@Query((_returns) => String) | ||
hello() { | ||
return "Hello world"; | ||
} | ||
} | ||
|
||
export const schema = buildSchemaSync({ | ||
resolvers: [DummyResolver], | ||
emitSchemaFile: process.env.NODE_ENV === "development", | ||
authChecker, | ||
}); |
Oops, something went wrong.
9fd3e01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: