Skip to content

Commit

Permalink
Add TContext to type resolvers
Browse files Browse the repository at this point in the history
Part of #574
  • Loading branch information
leebyron committed Nov 15, 2016
1 parent 914dde2 commit 6dbc12e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/type/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export type GraphQLScalarTypeConfig<TInternal, TExternal> = {
export class GraphQLObjectType {
name: string;
description: ?string;
isTypeOf: ?GraphQLIsTypeOfFn;
isTypeOf: ?GraphQLIsTypeOfFn<*, *>;

_typeConfig: GraphQLObjectTypeConfig<*, *>;
_fields: GraphQLFieldMap<*, *>;
Expand Down Expand Up @@ -511,19 +511,19 @@ export type GraphQLObjectTypeConfig<TSource, TContext> = {
name: string;
interfaces?: Thunk<?Array<GraphQLInterfaceType>>;
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>;
isTypeOf?: ?GraphQLIsTypeOfFn;
isTypeOf?: ?GraphQLIsTypeOfFn<TSource, TContext>;
description?: ?string
};

export type GraphQLTypeResolver = (
value: mixed,
context: mixed,
export type GraphQLTypeResolver<TSource, TContext> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo
) => ?GraphQLObjectType | ?string;

export type GraphQLIsTypeOfFn = (
source: mixed,
context: mixed,
export type GraphQLIsTypeOfFn<TSource, TContext> = (
source: TSource,
context: TContext,
info: GraphQLResolveInfo
) => boolean;

Expand Down Expand Up @@ -615,7 +615,7 @@ export type GraphQLFieldMap<TSource, TContext> = {
export class GraphQLInterfaceType {
name: string;
description: ?string;
resolveType: ?GraphQLTypeResolver;
resolveType: ?GraphQLTypeResolver<*, *>;

_typeConfig: GraphQLInterfaceTypeConfig<*, *>;
_fields: GraphQLFieldMap<*, *>;
Expand Down Expand Up @@ -653,7 +653,7 @@ export type GraphQLInterfaceTypeConfig<TSource, TContext> = {
* the default implementation will call `isTypeOf` on each implementing
* Object type.
*/
resolveType?: ?GraphQLTypeResolver,
resolveType?: ?GraphQLTypeResolver<TSource, TContext>,
description?: ?string
};

Expand Down Expand Up @@ -685,13 +685,13 @@ export type GraphQLInterfaceTypeConfig<TSource, TContext> = {
export class GraphQLUnionType {
name: string;
description: ?string;
resolveType: ?GraphQLTypeResolver;
resolveType: ?GraphQLTypeResolver<*, *>;

_typeConfig: GraphQLUnionTypeConfig;
_typeConfig: GraphQLUnionTypeConfig<*, *>;
_types: Array<GraphQLObjectType>;
_possibleTypeNames: {[typeName: string]: boolean};

constructor(config: GraphQLUnionTypeConfig) {
constructor(config: GraphQLUnionTypeConfig<*, *>) {
invariant(config.name, 'Type must be named.');
assertValidName(config.name);
this.name = config.name;
Expand Down Expand Up @@ -748,15 +748,15 @@ function defineTypes(
return types;
}

export type GraphQLUnionTypeConfig = {
export type GraphQLUnionTypeConfig<TSource, TContext> = {
name: string,
types: Thunk<Array<GraphQLObjectType>>,
/**
* Optionally provide a custom type resolver function. If one is not provided,
* the default implementation will call `isTypeOf` on each implementing
* Object type.
*/
resolveType?: ?GraphQLTypeResolver;
resolveType?: ?GraphQLTypeResolver<TSource, TContext>;
description?: ?string;
};

Expand Down

0 comments on commit 6dbc12e

Please sign in to comment.