Created
December 29, 2021 14:48
-
-
Save neerajkumar161/56df1dde2206f0857f31667fc193bf9d to your computer and use it in GitHub Desktop.
/src/schema-loader.ts
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 {loadFilesSync} from '@graphql-tools/load-files' | |
import {mergeTypeDefs} from '@graphql-tools/merge' | |
import {makeExecutableSchema} from '@graphql-tools/schema' | |
import * as path from 'path' | |
import { getUserByIdResolver } from './resolvers/get-user' | |
import { createUserResolver } from './resolvers/create-user' | |
const ROOT_SCHEMA_PATH = loadFilesSync(path.join(__dirname, './schemas')) | |
const TypeDefinition = mergeTypeDefs(ROOT_SCHEMA_PATH) | |
const resolvers = () => { | |
return { | |
Query: { | |
getUser: getUserByIdResolver, | |
}, | |
Mutation: { | |
createUser: createUserResolver, | |
} | |
} | |
} | |
const schema = () => | |
makeExecutableSchema({ | |
typeDefs: [TypeDefinition], | |
resolvers: resolvers() | |
}) | |
export const mainSchema = schema() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment