Skip to content

Commit 7472377

Browse files
committed
fix some conflict-types with Graphql
1 parent 7e58a89 commit 7472377

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

src/mutation/__tests__/mutation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('mutationWithClientMutationId()', () => {
9292
}
9393
}
9494
`;
95-
var result = await graphql(schema, query);
95+
var result:any = await graphql(schema, query);
9696
expect(result.errors.length).to.equal(1);
9797
expect(result.errors[0].message).to.equal('Field \"simpleMutation\" argument \"input\" of type \"SimpleMutationInput!\" is required but not provided.');
9898
});

src/mutation/mutation.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ import type {
2222
GraphQLResolveInfo
2323
} from 'graphql';
2424

25-
type mutationFn =
26-
(object: Object, ctx: Object, info: GraphQLResolveInfo) => Object |
27-
(object: Object, ctx: Object, info: GraphQLResolveInfo) => Promise<Object>;
25+
type mutationFn = (object: Object, ctx: mixed, info: GraphQLResolveInfo) =>
26+
( Object | Promise<Object> );
2827

2928
function resolveMaybeThunk<T>(thingOrThunk: T | () => T): T {
3029
return typeof thingOrThunk === 'function' ? thingOrThunk() : thingOrThunk;

src/node/node.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ type GraphQLNodeDefinitions = {
3030
nodeField: GraphQLFieldConfig
3131
}
3232

33-
type typeResolverFn = (object: any) => ?GraphQLObjectType |
34-
(object: any) => ?Promise<GraphQLObjectType>;
33+
type typeResolverFn = (object: any) => ?GraphQLObjectType;
3534

3635
/**
3736
* Given a function to map from an ID to an underlying object, and a function
@@ -45,7 +44,7 @@ type typeResolverFn = (object: any) => ?GraphQLObjectType |
4544
*/
4645
export function nodeDefinitions(
4746
idFetcher: ((id: string, context: any, info: GraphQLResolveInfo) => any),
48-
typeResolver?: ?typeResolverFn
47+
typeResolver?: typeResolverFn
4948
): GraphQLNodeDefinitions {
5049
var nodeInterface = new GraphQLInterfaceType({
5150
name: 'Node',

src/node/plural.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import type {
1717
GraphQLFieldConfig,
1818
GraphQLInputType,
1919
GraphQLOutputType,
20-
GraphQLResolveInfo
20+
GraphQLResolveInfo,
21+
GraphQLScalarType,
22+
GraphQLEnumType,
23+
GraphQLInputObjectType
2124
} from 'graphql';
2225

2326
type PluralIdentifyingRootFieldConfig = {
@@ -36,9 +39,7 @@ export function pluralIdentifyingRootField(
3639
inputArgs[config.argName] = {
3740
type: new GraphQLNonNull(
3841
new GraphQLList(
39-
new GraphQLNonNull(
40-
config.inputType
41-
)
42+
nonNull(config.inputType)
4243
)
4344
)
4445
};
@@ -56,3 +57,17 @@ export function pluralIdentifyingRootField(
5657
}
5758
};
5859
}
60+
61+
type NonNullInputType = GraphQLNonNull<
62+
GraphQLScalarType |
63+
GraphQLEnumType |
64+
GraphQLInputObjectType |
65+
GraphQLList<GraphQLInputType> >;
66+
67+
function nonNull(type:GraphQLInputType):NonNullInputType {
68+
if ( type instanceof GraphQLNonNull) {
69+
return type;
70+
} else {
71+
return new GraphQLNonNull(type);
72+
}
73+
}

0 commit comments

Comments
 (0)