Skip to content

Commit 97c4404

Browse files
committed
Fix flowtype errors
1 parent a1c510d commit 97c4404

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/mutationMiddleware.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* @flow */
22
/* eslint-disable no-param-reassign */
33

4-
import { ResolverMiddleware, TypeComposer, InputTypeComposer } from 'graphql-compose';
54
import {
65
GraphQLID,
76
GraphQLString,
@@ -10,6 +9,7 @@ import {
109
GraphQLInputObjectType,
1110
GraphQLNonNull,
1211
} from 'graphql';
12+
import { ResolverMiddleware, TypeComposer, InputTypeComposer } from 'graphql-compose';
1313
import { toGlobalId } from './globalId';
1414
import type {
1515
Resolver,
@@ -19,10 +19,14 @@ import type {
1919
ResolverMWResolve,
2020
ResolverMWOutputTypeFn,
2121
ResolverMWOutputType,
22+
ObjectMap,
2223
} from './definition';
2324

25+
2426
export default class MutationMiddleware extends ResolverMiddleware {
25-
constructor(typeComposer: TypeComposer, typeResolver: Resolver, opts: mixed = {}) {
27+
isArgsWrapped: boolean;
28+
29+
constructor(typeComposer: TypeComposer, typeResolver: Resolver, opts: ObjectMap = {}) {
2630
super(typeComposer, typeResolver, opts);
2731

2832
this.isArgsWrapped = false;
@@ -35,7 +39,10 @@ export default class MutationMiddleware extends ResolverMiddleware {
3539

3640
if (nextArgs.input && nextArgs.input.type) {
3741
// pass args unchanged
38-
inputTC = new InputTypeComposer(getNamedType(nextArgs.input.type));
42+
const inputNamedType = getNamedType(nextArgs.input.type);
43+
if (inputNamedType instanceof GraphQLInputObjectType) {
44+
inputTC = new InputTypeComposer(inputNamedType);
45+
}
3946
newNextArgs = nextArgs;
4047
} else {
4148
// create input arg, and put into all current args
@@ -53,7 +60,7 @@ export default class MutationMiddleware extends ResolverMiddleware {
5360
}
5461

5562
// add `clientMutationId` to args.input field
56-
if (!inputTC.hasField('clientMutationId')) {
63+
if (inputTC && !inputTC.hasField('clientMutationId')) {
5764
inputTC.addField('clientMutationId', {
5865
type: GraphQLString,
5966
description: 'The client mutation ID used by clients like Relay to track the mutation. '

src/nodeInterface.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
GraphQLInterfaceType,
77
} from 'graphql';
88

9+
910
const NodeInterface = new GraphQLInterfaceType({
1011
name: 'Node',
1112
description: 'An object, that can be fetched by the globally unique ID among all types.',
@@ -17,6 +18,7 @@ const NodeInterface = new GraphQLInterfaceType({
1718
}),
1819
resolveType: (payload) => {
1920
// `payload.__nodeType` was added to payload via nodeFieldConfig.resolve
21+
// $FlowFixMe
2022
return payload.__nodeType ? payload.__nodeType : null;
2123
},
2224
});

0 commit comments

Comments
 (0)