Skip to content

Commit

Permalink
fix(UnionTypeComposer): add support for graphql@0.13.0
Browse files Browse the repository at this point in the history
Closes #167
  • Loading branch information
nodkz committed Feb 7, 2019
1 parent cf92718 commit d7366e0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/UnionTypeComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { Thunk } from './utils/definitions';
import { resolveTypeArrayAsThunk } from './utils/configAsThunk';
// import { typeByPath } from './utils/typeByPath';
import { getGraphQLType, getComposeTypeName } from './utils/typeHelpers';
// import { graphqlVersion } from './utils/graphqlVersion';
import { graphqlVersion } from './utils/graphqlVersion';

export type GraphQLUnionTypeExtended<TSource, TContext> = GraphQLUnionType & {
_gqcTypeMap?: Map<string, ComposeObjectType>,
Expand Down Expand Up @@ -140,9 +140,16 @@ export class UnionTypeComposer<TContext> {
});
this.gqType._gqcTypeMap = m;

this.gqType._types = () => {
return resolveTypeArrayAsThunk(this.schemaComposer, this.getTypes(), this.getTypeName());
};
if (graphqlVersion >= 14) {
this.gqType._types = () => {
return resolveTypeArrayAsThunk(this.schemaComposer, this.getTypes(), this.getTypeName());
};
} else {
(this.gqType: any)._types = null;
(this.gqType: any)._typeConfig.types = () => {
return resolveTypeArrayAsThunk(this.schemaComposer, this.getTypes(), this.getTypeName());
};
}
}

return this.gqType._gqcTypeMap;
Expand Down

0 comments on commit d7366e0

Please sign in to comment.