Skip to content

Commit

Permalink
fix: multi schemaComposer mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Jun 6, 2018
1 parent a311f4e commit ebe828e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/wrapMutationResolver.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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),
});
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit ebe828e

Please sign in to comment.