Skip to content

Instantly share code, notes, and snippets.

@JeffML
Created September 3, 2017 21:20
Show Gist options
  • Save JeffML/0275eca0f23457355c09bbc8d4feddb2 to your computer and use it in GitHub Desktop.
Save JeffML/0275eca0f23457355c09bbc8d4feddb2 to your computer and use it in GitHub Desktop.
Step 1: adding
// This example demonstrates a simple server with some relational data: Posts and Authors. You can get the posts for a particular author,
// and vice-versa Read the complete docs for graphql-tools here: http://dev.apollodata.com/tools/graphql-tools/generate-schema.html
import {
makeExecutableSchema,
addMockFunctionsToSchema
} from 'graphql-tools';
import {
schema as authorpostsSchema,
resolvers as authorpostsResolvers
} from './authorposts';
import {
schema as myLittleTypoSchema,
resolvers as myLittleTypeResolvers
} from './myLittleDomain';
import {
merge
} from 'lodash';
const baseSchema = [
`
type Query {
domain: String
}
type Mutation {
domain: String
}
schema {
query: Query,
mutation: Mutation
}`
]
// Put schema together into one array of schema strings and one map of resolvers, like makeExecutableSchema expects
const schema = [...baseSchema, ...authorpostsSchema, ...myLittleTypoSchema]
const options = {
typeDefs: schema,
resolvers: merge(authorpostsResolvers, myLittleTypeResolvers)
}
const executableSchema = makeExecutableSchema(options);
addMockFunctionsToSchema({
schema: executableSchema
})
export default executableSchema;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment