Skip to content

Commit

Permalink
feat(types): update TypeResolver interface
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalLytek committed Oct 6, 2019
1 parent a894dd2 commit e32a34f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,7 @@
- **Breaking Change**: emit in schema only types actually used by provided resolvers classes (#415)
- **Breaking Change**: update `graphql-js` peer dependency to `^14.5.8`
- **Breaking Change**: update `graphql-query-complexity` dependency to `^0.4.0` and drop support for `fieldConfigEstimator` (use `fieldExtensionsEstimator` instead)
- update `TypeResolver` interface to match with `GraphQLTypeResolver` from `graphql-js`
### Fixes
- refactor union types function syntax handling to prevent possible errors with circular refs

Expand Down
6 changes: 2 additions & 4 deletions src/interfaces/TypeResolver.ts
@@ -1,10 +1,8 @@
import { GraphQLResolveInfo } from "graphql";
import { GraphQLTypeResolver } from "graphql";

import { ClassType } from "./ClassType";
import { MaybePromise, Maybe } from "./Maybe";

export type TypeResolver<TSource, TContext> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo,
...args: Parameters<GraphQLTypeResolver<TSource, TContext>>
) => MaybePromise<Maybe<string | ClassType>>;
4 changes: 2 additions & 2 deletions src/utils/createResolversMap.ts
Expand Up @@ -56,8 +56,8 @@ function generateTypeResolver(
schema: GraphQLSchema,
): GraphQLTypeResolver<any, any> {
if (abstractType.resolveType) {
return async (source, context, info) => {
const detectedType = await abstractType.resolveType!(source, context, info);
return async (...args) => {
const detectedType = await abstractType.resolveType!(...args);
if (detectedType instanceof GraphQLObjectType) {
return detectedType.name;
}
Expand Down

0 comments on commit e32a34f

Please sign in to comment.