From ebe828e610093531e0063368052bbc8edb7161a5 Mon Sep 17 00:00:00 2001 From: nodkz Date: Wed, 6 Jun 2018 21:19:53 +0600 Subject: [PATCH] fix: multi schemaComposer mode --- src/wrapMutationResolver.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wrapMutationResolver.js b/src/wrapMutationResolver.js index 901702b..e71827e 100644 --- a/src/wrapMutationResolver.js +++ b/src/wrapMutationResolver.js @@ -1,7 +1,7 @@ /* @flow */ /* eslint-disable no-param-reassign */ -import { TypeComposer, InputTypeComposer, type Resolver } from 'graphql-compose'; +import type { InputTypeComposer, Resolver } from 'graphql-compose'; import { GraphQLObjectType, getNamedType, @@ -25,18 +25,19 @@ export default function wrapMutationResolver( opts: WrapMutationResolverOpts ): Resolver { const { resolverName, rootTypeName } = opts; + const schemaComposer = resolver.constructor.schemaComposer; function prepareArgs(newResolver: Resolver) { let ITC: InputTypeComposer; if (newResolver.hasArg('input')) { const inputNamedType = getNamedType(newResolver.getArgType('input')); if (inputNamedType instanceof GraphQLInputObjectType) { - ITC = new InputTypeComposer(inputNamedType); + ITC = new schemaComposer.InputTypeComposer(inputNamedType); } } else { // create input arg, and put into all current args - ITC = InputTypeComposer.create({ + ITC = schemaComposer.InputTypeComposer.create({ name: `Relay${upperFirst(resolverName)}${rootTypeName}Input`, fields: (newResolver.args: any), }); @@ -93,7 +94,7 @@ export default function wrapMutationResolver( return; } - const outputTC = new TypeComposer(outputType); + const outputTC = new schemaComposer.TypeComposer(outputType); if (!outputTC.hasField('nodeId')) { outputTC.setField('nodeId', { type: 'ID',