Last active
October 11, 2017 05:48
-
-
Save aofleejay/0cf0e43ad4e2f88da080b28553067320 to your computer and use it in GitHub Desktop.
Create GraphQL schema at root schema
This file contains hidden or 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 { makeExecutableSchema } from 'graphql-tools' | |
import merge from 'lodash.merge' | |
import { | |
queries as fooQueries, | |
resolvers as fooResolvers, | |
typeDefinitions as fooTypeDefinitions, | |
} from './foo/schema' | |
import { | |
queries as barQueries, | |
resolvers as barResolvers, | |
typeDefinitions as barTypeDefinitions, | |
} from './bar/schema' | |
const moduleTypeDefinitions = [ | |
fooTypeDefinitions, | |
barTypeDefinitions, | |
] | |
const moduleQueries = [ | |
fooQueries, | |
barQueries, | |
] | |
const schema = ` | |
type Query { | |
${moduleQueries.join('\n')} | |
} | |
${moduleTypeDefinitions.join('\n')} | |
` | |
const resolvers = merge(fooResolvers, barResolvers) | |
export default makeExecutableSchema({ | |
typeDefs: [schema], | |
resolvers, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment