import Koa from 'koa'
import { ApolloServer, gql, makeExecutableSchema, mergeSchemas } from 'apollo-server-koa'
import depthLimit from 'graphql-depth-limit'
import voyager from './middleware/voyager'
// import schemaHandler from '../util/schema-handler'
import connectorFactory from '../util/connector-factory'
import connConfig from '../../connector'
const isDev = !(process.env.NODE_ENV === 'production')
async function start () {
// init apolloserver
const resolvers = {
AllowedColor: {
RED: '#f00',
GREEN: '#0f0',
BLUE: '#00f'
},
Query: {
favoriteColor: () => '#f00',
avatar: (parent, args) => {
return `${JSON.stringify(args)}`
}
}
}
const typeDefs = gql`
enum AllowedColor {
RED
GREEN
BLUE
}
type Query {
favoriteColor: AllowedColor # As a return value
avatar(borderColor: AllowedColor): String # As an argument
}
`
// const schema = makeExecutableSchema({ resolvers, typeDefs })
const schemas = [makeExecutableSchema({ resolvers, typeDefs })]
const schema = mergeSchemas({ schemas })
const server = new ApolloServer({
// schema: await schemaHandler(),
schema,
dataSources: connectorFactory(connConfig),
validationRules: [depthLimit(10)],
introspection: isDev,
playground: isDev,
tracing: isDev
})
const app = new Koa()
// register
server.applyMiddleware({ app })
// dev open voyager
isDev && app.use(voyager)
app.listen(process.env.PORT, () => {
console.log(
process.env.NODE_ENV === 'localhost'
? `Open ${'http://localhost:' + process.env.PORT}`
: `GCE listening on port ${process.env.PORT}`
)
})
}
start()

It works when I use makeExecutableSchema , but I use mergeSchemas to report an error.
Same issue as mine #1035. Because of the delegating resolvers here https://github.com/apollographql/graphql-tools/blob/master/src/stitching/mergeSchemas.ts#L446.
I guess AllowedColor is treated as InputType and resolved because you have AllowedColor in your resolvers because of these mappings here https://github.com/apollographql/graphql-tools/blob/master/src/stitching/schemaRecreation.ts#L207. I am still trying to figure out why mergeSchemas has to be so overly complex, error prone and overhead generating.
It works with your resolvers like this:
const resolvers = {
// AllowedColor: {
// RED: '#f00',
// GREEN: '#0f0',
// BLUE: '#00f'
// },
Query: {
favoriteColor: () => 'RED',
avatar: (parent, args) => {
return `${JSON.stringify(args)}`
}
}
}
That said, we should not have to think about that, it should behave the same.
EDIT: I reproduced it here https://github.com/kommander/graphql-tool-repro/tree/allowed-color
@kommander Thanks for your reply, all my backends expect to work with me using thrift RPC. The enum value of thrift RPC is INT, and unless mergeSchemas solves this problem, I have to give up this way.
Does this remain an issue? I seem to be encountering the same thing trying to stitch together a local and remote schema. The local is created from 19majkel94/type-graphql which uses the resolver method to allow internal enum values. This seems like a pretty major nuisance. Does anyone have a way around this?
Ran into this too problem too, definitely remains an issue. So basically you cannot merge schemas if they use enums?
I think @stefanprobst has fixed this in #1075.
Rolled into #1306
Most helpful comment
I think @stefanprobst has fixed this in #1075.