feat(graphql): add tsource and tcontext type parameters to graphql, fix #31941

This commit is contained in:
Sibelius Seraphini
2019-01-07 11:34:22 -02:00
parent 3ad75fac4d
commit 327548b830
5 changed files with 34 additions and 34 deletions
+3 -3
View File
@@ -136,7 +136,7 @@ export function buildExecutionContext(
*/
export function collectFields(
exeContext: ExecutionContext,
runtimeType: GraphQLObjectType,
runtimeType: GraphQLObjectType<any, any>,
selectionSet: SelectionSetNode,
fields: { [key: string]: Array<FieldNode> },
visitedFragmentNames: { [key: string]: boolean }
@@ -146,7 +146,7 @@ export function buildResolveInfo(
exeContext: ExecutionContext,
fieldDef: GraphQLField<any, any>,
fieldNodes: ReadonlyArray<FieldNode>,
parentType: GraphQLObjectType,
parentType: GraphQLObjectType<any, any>,
path: ResponsePath
): GraphQLResolveInfo;
@@ -180,6 +180,6 @@ export const defaultFieldResolver: GraphQLFieldResolver<any, any>;
*/
export function getFieldDef(
schema: GraphQLSchema,
parentType: GraphQLObjectType,
parentType: GraphQLObjectType<any, any>,
fieldName: string
): Maybe<GraphQLField<any, any>>;
+16 -16
View File
@@ -28,7 +28,7 @@ import { GraphQLSchema } from "./schema";
*/
export type GraphQLType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLObjectType<any, any>
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
@@ -44,9 +44,9 @@ export function isScalarType(type: any): type is GraphQLScalarType;
export function assertScalarType(type: any): GraphQLScalarType;
export function isObjectType(type: any): type is GraphQLObjectType;
export function isObjectType(type: any): type is GraphQLObjectType<any, any>;
export function assertObjectType(type: any): GraphQLObjectType;
export function assertObjectType(type: any): GraphQLObjectType<any, any>;
export function isInterfaceType(type: any): type is GraphQLInterfaceType;
@@ -91,14 +91,14 @@ export function assertInputType(type: any): GraphQLInputType;
*/
export type GraphQLOutputType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLObjectType<any, any>
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLList<any>
| GraphQLNonNull<
| GraphQLScalarType
| GraphQLObjectType
| GraphQLObjectType<any, any>
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
@@ -121,7 +121,7 @@ export function assertLeafType(type: any): GraphQLLeafType;
/**
* These types may describe the parent context of a selection set.
*/
export type GraphQLCompositeType = GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType;
export type GraphQLCompositeType = GraphQLObjectType<any, any> | GraphQLInterfaceType | GraphQLUnionType;
export function isCompositeType(type: any): type is GraphQLCompositeType;
@@ -214,7 +214,7 @@ export function assertWrappingType(type: any): GraphQLWrappingType;
*/
export type GraphQLNullableType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLObjectType<any, any>
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
@@ -234,7 +234,7 @@ export function getNullableType<T extends GraphQLNullableType>(type: GraphQLNonN
*/
export type GraphQLNamedType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLObjectType<any, any>
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
@@ -342,15 +342,15 @@ export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
* });
*
*/
export class GraphQLObjectType {
export class GraphQLObjectType<TSource, TContext> {
name: string;
description: Maybe<string>;
astNode: Maybe<ObjectTypeDefinitionNode>;
extensionASTNodes: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
isTypeOf: Maybe<GraphQLIsTypeOfFn<any, any>>;
isTypeOf: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
constructor(config: GraphQLObjectTypeConfig<any, any>);
getFields(): GraphQLFieldMap<any, any>;
constructor(config: GraphQLObjectTypeConfig<TSource, TContext>);
getFields(): GraphQLFieldMap<any, TContext>;
getInterfaces(): GraphQLInterfaceType[];
toString(): string;
toJSON(): string;
@@ -371,7 +371,7 @@ export type GraphQLTypeResolver<TSource, TContext> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo
) => MaybePromise<Maybe<GraphQLObjectType | string>>;
) => MaybePromise<Maybe<GraphQLObjectType<TSource, TContext> | string>>;
export type GraphQLIsTypeOfFn<TSource, TContext> = (
source: TSource,
@@ -390,7 +390,7 @@ export interface GraphQLResolveInfo {
readonly fieldName: string;
readonly fieldNodes: ReadonlyArray<FieldNode>;
readonly returnType: GraphQLOutputType;
readonly parentType: GraphQLObjectType;
readonly parentType: GraphQLObjectType<any, any>;
readonly path: ResponsePath;
readonly schema: GraphQLSchema;
readonly fragments: { [key: string]: FragmentDefinitionNode };
@@ -533,7 +533,7 @@ export class GraphQLUnionType {
constructor(config: GraphQLUnionTypeConfig<any, any>);
getTypes(): GraphQLObjectType[];
getTypes(): GraphQLObjectType<any, any>[];
toString(): string;
toJSON(): string;
@@ -542,7 +542,7 @@ export class GraphQLUnionType {
export interface GraphQLUnionTypeConfig<TSource, TContext> {
name: string;
types: Thunk<GraphQLObjectType[]>;
types: Thunk<GraphQLObjectType<any, any>[]>;
/**
* Optionally provide a custom type resolver function. If one is not provided,
* the default implementation will call `isTypeOf` on each implementing
+6 -6
View File
@@ -10,13 +10,13 @@ import {
} from "./definition";
import { GraphQLField } from "./definition";
export const __Schema: GraphQLObjectType;
export const __Directive: GraphQLObjectType;
export const __Schema: GraphQLObjectType<any, any>;
export const __Directive: GraphQLObjectType<any, any>;
export const __DirectiveLocation: GraphQLEnumType;
export const __Type: GraphQLObjectType;
export const __Field: GraphQLObjectType;
export const __InputValue: GraphQLObjectType;
export const __EnumValue: GraphQLObjectType;
export const __Type: GraphQLObjectType<any, any>;
export const __Field: GraphQLObjectType<any, any>;
export const __InputValue: GraphQLObjectType<any, any>;
export const __EnumValue: GraphQLObjectType<any, any>;
export const TypeKind: {
SCALAR: "SCALAR";
+8 -8
View File
@@ -41,14 +41,14 @@ export class GraphQLSchema {
constructor(config: GraphQLSchemaConfig);
getQueryType(): Maybe<GraphQLObjectType>;
getMutationType(): Maybe<GraphQLObjectType>;
getSubscriptionType(): Maybe<GraphQLObjectType>;
getQueryType(): Maybe<GraphQLObjectType<any, any>>;
getMutationType(): Maybe<GraphQLObjectType<any, any>>;
getSubscriptionType(): Maybe<GraphQLObjectType<any, any>>;
getTypeMap(): TypeMap;
getType(name: string): Maybe<GraphQLNamedType>;
getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray<GraphQLObjectType>;
getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray<GraphQLObjectType<any, any>>;
isPossibleType(abstractType: GraphQLAbstractType, possibleType: GraphQLObjectType): boolean;
isPossibleType(abstractType: GraphQLAbstractType, possibleType: GraphQLObjectType<any, any>): boolean;
getDirectives(): ReadonlyArray<GraphQLDirective>;
getDirective(name: string): Maybe<GraphQLDirective>;
@@ -77,9 +77,9 @@ export interface GraphQLSchemaValidationOptions {
}
export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
query: Maybe<GraphQLObjectType>;
mutation?: Maybe<GraphQLObjectType>;
subscription?: Maybe<GraphQLObjectType>;
query: Maybe<GraphQLObjectType<any, any>>;
mutation?: Maybe<GraphQLObjectType<any, any>>;
subscription?: Maybe<GraphQLObjectType<any, any>>;
types?: Maybe<GraphQLNamedType[]>;
directives?: Maybe<GraphQLDirective[]>;
astNode?: Maybe<SchemaDefinitionNode>;
+1 -1
View File
@@ -8,4 +8,4 @@ import { GraphQLObjectType } from "../type/definition";
export function getOperationRootType(
schema: GraphQLSchema,
operation: OperationDefinitionNode | OperationTypeDefinitionNode
): GraphQLObjectType;
): GraphQLObjectType<any, any>;