You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
demo-graphql-oauth/src/schema.ts

24 lines
600 B

import { DocumentNode, graphql, GraphQLSchema } from "graphql"
import { buildSchema } from "type-graphql"
import { customAuthChecker } from "./auth"
import { UserResolver } from "./User/UserResolver"
let schema: GraphQLSchema
export const callSchema = async (document: DocumentNode, context?: any) => {
if (!schema) {
schema = await createSchema()
}
return graphql({
schema,
source: document.loc!.source.body || "",
contextValue: context,
})
}
export const createSchema = () =>
buildSchema({
resolvers: [UserResolver],
authChecker: customAuthChecker,
})