From 619d2fcc39dad12a5512eb55523f8fac7b4a44d5 Mon Sep 17 00:00:00 2001 From: Firede Date: Mon, 27 Mar 2017 17:14:47 +0800 Subject: [PATCH 1/8] `keyMap` is optional. --- types/graphql/language/visitor.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/graphql/language/visitor.d.ts b/types/graphql/language/visitor.d.ts index 1d0f399d6e..d4c528501e 100644 --- a/types/graphql/language/visitor.d.ts +++ b/types/graphql/language/visitor.d.ts @@ -42,7 +42,7 @@ export const QueryDocumentKeys: { export const BREAK: any; -export function visit(root: any, visitor: any, keyMap: any): any; +export function visit(root: any, visitor: any, keyMap?: any): any; export function visitInParallel(visitors: any): any; From 352a5756b1db52cc6cb3407dddf487843c297de0 Mon Sep 17 00:00:00 2001 From: Firede Date: Mon, 27 Mar 2017 17:15:50 +0800 Subject: [PATCH 2/8] `operationName` is optional. --- types/graphql/utilities/getOperationAST.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/graphql/utilities/getOperationAST.d.ts b/types/graphql/utilities/getOperationAST.d.ts index 65c7735a5d..ce99d39b2b 100644 --- a/types/graphql/utilities/getOperationAST.d.ts +++ b/types/graphql/utilities/getOperationAST.d.ts @@ -7,5 +7,5 @@ import { DocumentNode, OperationDefinitionNode } from '../language/ast'; */ export function getOperationAST( documentAST: DocumentNode, - operationName: string + operationName?: string ): OperationDefinitionNode; From 67dba4b5a78f585c2f74c8531ba7b6cfd72050be Mon Sep 17 00:00:00 2001 From: Firede Date: Mon, 27 Mar 2017 17:16:24 +0800 Subject: [PATCH 3/8] add `findDeprecatedUsages`. --- types/graphql/utilities/findDeprecatedUsages.d.ts | 13 +++++++++++++ types/graphql/utilities/index.d.ts | 3 +++ 2 files changed, 16 insertions(+) create mode 100644 types/graphql/utilities/findDeprecatedUsages.d.ts diff --git a/types/graphql/utilities/findDeprecatedUsages.d.ts b/types/graphql/utilities/findDeprecatedUsages.d.ts new file mode 100644 index 0000000000..58e9ae1685 --- /dev/null +++ b/types/graphql/utilities/findDeprecatedUsages.d.ts @@ -0,0 +1,13 @@ +import { GraphQLSchema } from '../type/schema'; +import { DocumentNode } from '../language/ast'; +import { GraphQLError } from '../error/GraphQLError'; + +/** + * A validation rule which reports deprecated usages. + * + * Returns a list of GraphQLError instances describing each deprecated use. + */ +export function findDeprecatedUsages( + schema: GraphQLSchema, + ast: DocumentNode +): Array diff --git a/types/graphql/utilities/index.d.ts b/types/graphql/utilities/index.d.ts index 47cfd70ff9..8815046735 100644 --- a/types/graphql/utilities/index.d.ts +++ b/types/graphql/utilities/index.d.ts @@ -73,3 +73,6 @@ export { assertValidName } from './assertValidName'; // Compares two GraphQLSchemas and detects breaking changes. export { findBreakingChanges } from './findBreakingChanges'; export { BreakingChange } from './findBreakingChanges'; + +// Report all deprecated usage within a GraphQL document. +export { findDeprecatedUsages } from './findDeprecatedUsages'; From 7fdcaa77107727c610432d76f1faefbac761816b Mon Sep 17 00:00:00 2001 From: Firede Date: Mon, 27 Mar 2017 17:19:40 +0800 Subject: [PATCH 4/8] remove duplicate functions. --- types/graphql/index.d.ts | 2 +- types/graphql/utilities/buildASTSchema.d.ts | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index 43d810de02..b6d02d7026 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for graphql v0.8.2 // Project: https://www.npmjs.com/package/graphql -// Definitions by: TonyYang , Caleb Meredith , Dominic Watson +// Definitions by: TonyYang , Caleb Meredith , Dominic Watson , Firede // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/graphql/utilities/buildASTSchema.d.ts b/types/graphql/utilities/buildASTSchema.d.ts index cf782a30ec..94f4e2a47a 100644 --- a/types/graphql/utilities/buildASTSchema.d.ts +++ b/types/graphql/utilities/buildASTSchema.d.ts @@ -26,15 +26,3 @@ export function getDescription(node: { loc?: Location }): string; * document. */ export function buildSchema(source: string | Source): GraphQLSchema; - -/** - * Given an ast node, returns its string description based on a contiguous - * block full-line of comments preceding it. - */ -export function getDescription(node: { loc?: Location }): string; - -/** - * A helper function to build a GraphQLSchema directly from a source - * document. - */ -export function buildSchema(source: string | Source): GraphQLSchema; From ad9c5dd1d2e0556d80e1848c284a773fd8bdc8e8 Mon Sep 17 00:00:00 2001 From: Firede Date: Mon, 27 Mar 2017 18:58:40 +0800 Subject: [PATCH 5/8] add `findBreakingChanges` & `findDeprecatedUsages` --- types/graphql/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index b6d02d7026..9eef11de76 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -105,6 +105,12 @@ export { // Asserts a string is a valid GraphQL name. assertValidName, + // Compares two GraphQLSchemas and detects breaking changes. + findBreakingChanges, + + // Report all deprecated usage within a GraphQL document. + findDeprecatedUsages, + BreakingChange, IntrospectionDirective, From 68436998439a29d30bd2d68f4e6b1d141e51a59e Mon Sep 17 00:00:00 2001 From: Firede Date: Mon, 27 Mar 2017 19:00:26 +0800 Subject: [PATCH 6/8] add `isNamedType` & `assertNamedType`. promisify isTypeOf and resolveType. --- types/graphql/index.d.ts | 2 +- types/graphql/type/definition.d.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index 9eef11de76..95c7bc5b37 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for graphql v0.8.2 +// Type definitions for graphql v0.9.1 // Project: https://www.npmjs.com/package/graphql // Definitions by: TonyYang , Caleb Meredith , Dominic Watson , Firede // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/graphql/type/definition.d.ts b/types/graphql/type/definition.d.ts index 6fef914d8e..3d6beae33d 100644 --- a/types/graphql/type/definition.d.ts +++ b/types/graphql/type/definition.d.ts @@ -126,6 +126,10 @@ export type GraphQLNamedType = GraphQLEnumType | GraphQLInputObjectType; +export function isNamedType(type: GraphQLType): boolean; + +export function assertNamedType(type: GraphQLType): GraphQLNamedType; + export function getNamedType(type: GraphQLType): GraphQLNamedType; /** @@ -237,13 +241,13 @@ export type GraphQLTypeResolver = ( value: TSource, context: TContext, info: GraphQLResolveInfo -) => GraphQLObjectType; +) => GraphQLObjectType | string | Promise; export type GraphQLIsTypeOfFn = ( source: TSource, context: TContext, info: GraphQLResolveInfo -) => boolean; +) => boolean | Promise; export type GraphQLFieldResolver = ( source: TSource, From a1b59d6a0f602b47ab05e0c6e52200c881c67d06 Mon Sep 17 00:00:00 2001 From: Firede Date: Mon, 27 Mar 2017 19:08:48 +0800 Subject: [PATCH 7/8] add TypeInfo.getEnumValue and EnumType.getValue --- types/graphql/type/definition.d.ts | 1 + types/graphql/utilities/TypeInfo.d.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/graphql/type/definition.d.ts b/types/graphql/type/definition.d.ts index 3d6beae33d..656ac7253c 100644 --- a/types/graphql/type/definition.d.ts +++ b/types/graphql/type/definition.d.ts @@ -430,6 +430,7 @@ export class GraphQLEnumType { constructor(config: GraphQLEnumTypeConfig); getValues(): Array; + getValue(name: string): GraphQLEnumValue; serialize(value: any): string; parseValue(value: any): any; parseLiteral(valueNode: ValueNode): any; diff --git a/types/graphql/utilities/TypeInfo.d.ts b/types/graphql/utilities/TypeInfo.d.ts index 2957114ae5..b4fa855569 100644 --- a/types/graphql/utilities/TypeInfo.d.ts +++ b/types/graphql/utilities/TypeInfo.d.ts @@ -5,6 +5,7 @@ import { GraphQLInputType, GraphQLField, GraphQLArgument, + GraphQLEnumValue, GraphQLType, } from '../type/definition'; import { GraphQLDirective } from '../type/directives'; @@ -30,6 +31,7 @@ export class TypeInfo { getFieldDef(): GraphQLField; getDirective(): GraphQLDirective; getArgument(): GraphQLArgument; + getEnumValue(): GraphQLEnumValue; enter(node: ASTNode): any; leave(node: ASTNode): any; } @@ -40,4 +42,4 @@ export interface getFieldDef { parentType: GraphQLType, fieldNode: FieldNode ): GraphQLField -} \ No newline at end of file +} From 57caf932118e8e086b6172bb66c393f619263064 Mon Sep 17 00:00:00 2001 From: Firede Date: Mon, 27 Mar 2017 19:37:17 +0800 Subject: [PATCH 8/8] fixed lint errors. --- types/graphql/error/GraphQLError.d.ts | 10 +++++----- types/graphql/index.d.ts | 2 +- types/graphql/language/ast.d.ts | 2 +- types/graphql/type/definition.d.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/types/graphql/error/GraphQLError.d.ts b/types/graphql/error/GraphQLError.d.ts index 12f65a506c..857f25b593 100644 --- a/types/graphql/error/GraphQLError.d.ts +++ b/types/graphql/error/GraphQLError.d.ts @@ -27,7 +27,7 @@ export class GraphQLError extends Error { * * Enumerable, and appears in the result of JSON.stringify(). */ - locations?: Array<{ line: number, column: number }> | void; + locations?: Array<{ line: number, column: number }> | undefined; /** * An array describing the JSON-path into the execution response which @@ -35,23 +35,23 @@ export class GraphQLError extends Error { * * Enumerable, and appears in the result of JSON.stringify(). */ - path?: Array | void; + path?: Array | undefined; /** * An array of GraphQL AST Nodes corresponding to this error. */ - nodes?: Array | void; + nodes?: Array | undefined; /** * The source GraphQL document corresponding to this error. */ - source?: Source | void; + source?: Source | undefined; /** * An array of character offsets within the source GraphQL document * which correspond to this error. */ - positions?: Array | void; + positions?: Array | undefined; /** * The original error thrown from a field resolver during execution. diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index 95c7bc5b37..de2a1405e6 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for graphql v0.9.1 +// Type definitions for graphql 0.9 // Project: https://www.npmjs.com/package/graphql // Definitions by: TonyYang , Caleb Meredith , Dominic Watson , Firede // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/graphql/language/ast.d.ts b/types/graphql/language/ast.d.ts index 238cbe7210..d0f25b65d0 100644 --- a/types/graphql/language/ast.d.ts +++ b/types/graphql/language/ast.d.ts @@ -85,7 +85,7 @@ export type Token = { /** * For non-punctuation tokens, represents the interpreted value of the token. */ - value: string | void; + value: string | undefined; /** * Tokens exist as nodes in a double-linked-list amongst all tokens diff --git a/types/graphql/type/definition.d.ts b/types/graphql/type/definition.d.ts index 656ac7253c..cf077ad5ba 100644 --- a/types/graphql/type/definition.d.ts +++ b/types/graphql/type/definition.d.ts @@ -269,7 +269,7 @@ export interface GraphQLResolveInfo { variableValues: { [variableName: string]: any }; } -export type ResponsePath = { prev: ResponsePath, key: string | number } | void; +export type ResponsePath = { prev: ResponsePath, key: string | number } | undefined; export interface GraphQLFieldConfig { type: GraphQLOutputType;