From 327548b8300ff2c930bc42bc9d60f7205b569147 Mon Sep 17 00:00:00 2001 From: Sibelius Seraphini Date: Mon, 7 Jan 2019 11:34:22 -0200 Subject: [PATCH] feat(graphql): add tsource and tcontext type parameters to graphql, fix #31941 --- types/graphql/execution/execute.d.ts | 6 ++-- types/graphql/type/definition.d.ts | 32 +++++++++---------- types/graphql/type/introspection.d.ts | 12 +++---- types/graphql/type/schema.d.ts | 16 +++++----- .../utilities/getOperationRootType.d.ts | 2 +- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/types/graphql/execution/execute.d.ts b/types/graphql/execution/execute.d.ts index fc6ad898d1..aff0cc0dd3 100644 --- a/types/graphql/execution/execute.d.ts +++ b/types/graphql/execution/execute.d.ts @@ -136,7 +136,7 @@ export function buildExecutionContext( */ export function collectFields( exeContext: ExecutionContext, - runtimeType: GraphQLObjectType, + runtimeType: GraphQLObjectType, selectionSet: SelectionSetNode, fields: { [key: string]: Array }, visitedFragmentNames: { [key: string]: boolean } @@ -146,7 +146,7 @@ export function buildResolveInfo( exeContext: ExecutionContext, fieldDef: GraphQLField, fieldNodes: ReadonlyArray, - parentType: GraphQLObjectType, + parentType: GraphQLObjectType, path: ResponsePath ): GraphQLResolveInfo; @@ -180,6 +180,6 @@ export const defaultFieldResolver: GraphQLFieldResolver; */ export function getFieldDef( schema: GraphQLSchema, - parentType: GraphQLObjectType, + parentType: GraphQLObjectType, fieldName: string ): Maybe>; diff --git a/types/graphql/type/definition.d.ts b/types/graphql/type/definition.d.ts index 1df7c85690..a33c81cd3b 100644 --- a/types/graphql/type/definition.d.ts +++ b/types/graphql/type/definition.d.ts @@ -28,7 +28,7 @@ import { GraphQLSchema } from "./schema"; */ export type GraphQLType = | GraphQLScalarType - | GraphQLObjectType + | GraphQLObjectType | 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; -export function assertObjectType(type: any): GraphQLObjectType; +export function assertObjectType(type: any): GraphQLObjectType; export function isInterfaceType(type: any): type is GraphQLInterfaceType; @@ -91,14 +91,14 @@ export function assertInputType(type: any): GraphQLInputType; */ export type GraphQLOutputType = | GraphQLScalarType - | GraphQLObjectType + | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType | GraphQLList | GraphQLNonNull< | GraphQLScalarType - | GraphQLObjectType + | GraphQLObjectType | 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 | 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 | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType @@ -234,7 +234,7 @@ export function getNullableType(type: GraphQLNonN */ export type GraphQLNamedType = | GraphQLScalarType - | GraphQLObjectType + | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType @@ -342,15 +342,15 @@ export interface GraphQLScalarTypeConfig { * }); * */ -export class GraphQLObjectType { +export class GraphQLObjectType { name: string; description: Maybe; astNode: Maybe; extensionASTNodes: Maybe>; - isTypeOf: Maybe>; + isTypeOf: Maybe>; - constructor(config: GraphQLObjectTypeConfig); - getFields(): GraphQLFieldMap; + constructor(config: GraphQLObjectTypeConfig); + getFields(): GraphQLFieldMap; getInterfaces(): GraphQLInterfaceType[]; toString(): string; toJSON(): string; @@ -371,7 +371,7 @@ export type GraphQLTypeResolver = ( value: TSource, context: TContext, info: GraphQLResolveInfo -) => MaybePromise>; +) => MaybePromise | string>>; export type GraphQLIsTypeOfFn = ( source: TSource, @@ -390,7 +390,7 @@ export interface GraphQLResolveInfo { readonly fieldName: string; readonly fieldNodes: ReadonlyArray; readonly returnType: GraphQLOutputType; - readonly parentType: GraphQLObjectType; + readonly parentType: GraphQLObjectType; readonly path: ResponsePath; readonly schema: GraphQLSchema; readonly fragments: { [key: string]: FragmentDefinitionNode }; @@ -533,7 +533,7 @@ export class GraphQLUnionType { constructor(config: GraphQLUnionTypeConfig); - getTypes(): GraphQLObjectType[]; + getTypes(): GraphQLObjectType[]; toString(): string; toJSON(): string; @@ -542,7 +542,7 @@ export class GraphQLUnionType { export interface GraphQLUnionTypeConfig { name: string; - types: Thunk; + types: Thunk[]>; /** * Optionally provide a custom type resolver function. If one is not provided, * the default implementation will call `isTypeOf` on each implementing diff --git a/types/graphql/type/introspection.d.ts b/types/graphql/type/introspection.d.ts index beed0ebeb2..6047f7a3bd 100644 --- a/types/graphql/type/introspection.d.ts +++ b/types/graphql/type/introspection.d.ts @@ -10,13 +10,13 @@ import { } from "./definition"; import { GraphQLField } from "./definition"; -export const __Schema: GraphQLObjectType; -export const __Directive: GraphQLObjectType; +export const __Schema: GraphQLObjectType; +export const __Directive: GraphQLObjectType; export const __DirectiveLocation: GraphQLEnumType; -export const __Type: GraphQLObjectType; -export const __Field: GraphQLObjectType; -export const __InputValue: GraphQLObjectType; -export const __EnumValue: GraphQLObjectType; +export const __Type: GraphQLObjectType; +export const __Field: GraphQLObjectType; +export const __InputValue: GraphQLObjectType; +export const __EnumValue: GraphQLObjectType; export const TypeKind: { SCALAR: "SCALAR"; diff --git a/types/graphql/type/schema.d.ts b/types/graphql/type/schema.d.ts index 7ccb390dbe..5d5a409af2 100644 --- a/types/graphql/type/schema.d.ts +++ b/types/graphql/type/schema.d.ts @@ -41,14 +41,14 @@ export class GraphQLSchema { constructor(config: GraphQLSchemaConfig); - getQueryType(): Maybe; - getMutationType(): Maybe; - getSubscriptionType(): Maybe; + getQueryType(): Maybe>; + getMutationType(): Maybe>; + getSubscriptionType(): Maybe>; getTypeMap(): TypeMap; getType(name: string): Maybe; - getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray; + getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray>; - isPossibleType(abstractType: GraphQLAbstractType, possibleType: GraphQLObjectType): boolean; + isPossibleType(abstractType: GraphQLAbstractType, possibleType: GraphQLObjectType): boolean; getDirectives(): ReadonlyArray; getDirective(name: string): Maybe; @@ -77,9 +77,9 @@ export interface GraphQLSchemaValidationOptions { } export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions { - query: Maybe; - mutation?: Maybe; - subscription?: Maybe; + query: Maybe>; + mutation?: Maybe>; + subscription?: Maybe>; types?: Maybe; directives?: Maybe; astNode?: Maybe; diff --git a/types/graphql/utilities/getOperationRootType.d.ts b/types/graphql/utilities/getOperationRootType.d.ts index e1f88e7e13..b1ec93d02e 100644 --- a/types/graphql/utilities/getOperationRootType.d.ts +++ b/types/graphql/utilities/getOperationRootType.d.ts @@ -8,4 +8,4 @@ import { GraphQLObjectType } from "../type/definition"; export function getOperationRootType( schema: GraphQLSchema, operation: OperationDefinitionNode | OperationTypeDefinitionNode -): GraphQLObjectType; +): GraphQLObjectType;