Merge pull request #28587 from firede/graphql-v14-release

[graphql] Update to v14.0.0
This commit is contained in:
Mine Starks
2018-09-05 09:18:35 -07:00
committed by GitHub
61 changed files with 381 additions and 177 deletions
+2 -2
View File
@@ -59,12 +59,12 @@ export class GraphQLError extends Error {
/**
* The original error thrown from a field resolver during execution.
*/
readonly originalError: Maybe<Error>;
readonly originalError: Maybe<Error> & { readonly extensions: any };
/**
* Extension fields to add to the formatted error.
*/
readonly extensions: { [key: string]: any } | void;
readonly extensions: { [key: string]: any } | undefined;
constructor(
message: string,
+1 -2
View File
@@ -11,6 +11,5 @@ export interface GraphQLFormattedError {
readonly message: string;
readonly locations: ReadonlyArray<SourceLocation> | undefined;
readonly path: ReadonlyArray<string | number> | undefined;
// Extensions
readonly [key: string]: any;
readonly extensions?: { [key: string]: any };
}
+1 -1
View File
@@ -7,7 +7,7 @@ import { ASTNode } from "../language/ast";
* document responsible for the original Error.
*/
export function locatedError(
originalError: Error,
originalError: Error | GraphQLError,
nodes: ReadonlyArray<ASTNode>,
path: ReadonlyArray<string | number>
): GraphQLError;
-5
View File
@@ -126,11 +126,6 @@ export function buildExecutionContext(
fieldResolver: Maybe<GraphQLFieldResolver<any, any>>
): ReadonlyArray<GraphQLError> | ExecutionContext;
/**
* Extracts the root type of the operation from the schema.
*/
export function getOperationRootType(schema: GraphQLSchema, operation: OperationDefinitionNode): GraphQLObjectType;
/**
* Given a selectionSet, adds all of the fields in that selection to
* the passed in map of fields, and returns it at the end.
+1 -1
View File
@@ -1,5 +1,5 @@
import Maybe from "../tsutils/Maybe";
import { GraphQLError } from "../error";
import { GraphQLError } from "../error/GraphQLError";
import { GraphQLInputType, GraphQLField, GraphQLArgument } from "../type/definition";
import { GraphQLDirective } from "../type/directives";
import { GraphQLSchema } from "../type/schema";
+5
View File
@@ -22,6 +22,11 @@ import { ExecutionResult, ExecutionResultDataDefault } from "./execution/execute
* rootValue:
* The value provided as the first argument to resolver functions on the top
* level type (e.g. the query object type).
* contextValue:
* The context value is provided as an argument to resolver functions after
* field arguments. It is used to pass shared information useful at any point
* during executing this query, for example the currently logged in user and
* connections to databases or other services.
* variableValues:
* A mapping of variable name to runtime value to use for all variables
* defined in the requestString.
+33 -9
View File
@@ -1,4 +1,4 @@
// Type definitions for graphql 0.13
// Type definitions for graphql 14.0
// Project: https://www.npmjs.com/package/graphql
// Definitions by: TonyYang <https://github.com/TonyPythoneer>
// Caleb Meredith <https://github.com/calebmer>
@@ -84,6 +84,8 @@ export {
isWrappingType,
isNullableType,
isNamedType,
isRequiredArgument,
isRequiredInputField,
isSpecifiedScalarType,
isIntrospectionType,
isSpecifiedDirective,
@@ -149,6 +151,9 @@ export {
GraphQLTypeResolver,
GraphQLUnionTypeConfig,
GraphQLDirectiveConfig,
GraphQLScalarSerializer,
GraphQLScalarValueParser,
GraphQLScalarLiteralParser,
} from "./type";
// Parse and operate on GraphQL language source files.
@@ -170,6 +175,16 @@ export {
TokenKind,
DirectiveLocation,
BREAK,
// Predicates
isDefinitionNode,
isExecutableDefinitionNode,
isSelectionNode,
isValueNode,
isTypeNode,
isTypeSystemDefinitionNode,
isTypeDefinitionNode,
isTypeSystemExtensionNode,
isTypeExtensionNode,
// type
Lexer,
ParseOptions,
@@ -227,9 +242,16 @@ export {
EnumTypeDefinitionNode,
EnumValueDefinitionNode,
InputObjectTypeDefinitionNode,
TypeExtensionNode,
ObjectTypeExtensionNode,
DirectiveDefinitionNode,
TypeSystemExtensionNode,
SchemaExtensionNode,
TypeExtensionNode,
ScalarTypeExtensionNode,
ObjectTypeExtensionNode,
InterfaceTypeExtensionNode,
UnionTypeExtensionNode,
EnumTypeExtensionNode,
InputObjectTypeExtensionNode,
KindEnum,
TokenKindEnum,
DirectiveLocationEnum,
@@ -268,7 +290,7 @@ export {
NoUnusedVariablesRule,
OverlappingFieldsCanBeMergedRule,
PossibleFragmentSpreadsRule,
ProvidedNonNullArgumentsRule,
ProvidedRequiredArgumentsRule,
ScalarLeafsRule,
SingleFieldSubscriptionsRule,
UniqueArgumentNamesRule,
@@ -279,7 +301,6 @@ export {
UniqueVariableNamesRule,
ValuesOfCorrectTypeRule,
VariablesAreInputTypesRule,
VariablesDefaultValueAllowedRule,
VariablesInAllowedPositionRule,
} from "./validation";
@@ -291,10 +312,12 @@ export {
// Produce the GraphQL query recommended for a full schema introspection.
// Accepts optional IntrospectionOptions.
getIntrospectionQuery,
// Deprecated: use getIntrospectionQuery
// @deprecated: use getIntrospectionQuery - will be removed in v15
introspectionQuery,
// Gets the target Operation from a Document
getOperationAST,
// Gets the Type for the target Operation AST.
getOperationRootType,
// Convert a GraphQLSchema to an IntrospectionQuery
introspectionFromSchema,
// Build a GraphQLSchema from an introspection result.
@@ -303,7 +326,8 @@ export {
buildASTSchema,
// Build a GraphQLSchema from a GraphQL schema language document.
buildSchema,
// Get the description from a schema AST node.
// @deprecated: Get the description from a schema AST node and supports legacy
// syntax for specifying descriptions - will be removed in v16
getDescription,
// Extends an existing GraphQLSchema from a parsed GraphQL Schema
// language AST.
@@ -330,9 +354,9 @@ export {
TypeInfo,
// Coerces a JavaScript value to a GraphQL type, or produces errors.
coerceValue,
// @deprecated use coerceValue
// @deprecated use coerceValue - will be removed in v15
isValidJSValue,
// Determine if AST values adhere to a GraphQL type.
// @deprecated use validation - will be removed in v15
isValidLiteralValue,
// Concatenates multiple AST together.
concatAST,
+31 -21
View File
@@ -115,13 +115,14 @@ export type ASTNode =
| EnumTypeDefinitionNode
| EnumValueDefinitionNode
| InputObjectTypeDefinitionNode
| DirectiveDefinitionNode
| SchemaExtensionNode
| ScalarTypeExtensionNode
| ObjectTypeExtensionNode
| InterfaceTypeExtensionNode
| UnionTypeExtensionNode
| EnumTypeExtensionNode
| InputObjectTypeExtensionNode
| DirectiveDefinitionNode;
| InputObjectTypeExtensionNode;
/**
* Utility type listing all nodes indexed by their kind.
@@ -162,13 +163,14 @@ export interface ASTKindToNode {
EnumTypeDefinition: EnumTypeDefinitionNode;
EnumValueDefinition: EnumValueDefinitionNode;
InputObjectTypeDefinition: InputObjectTypeDefinitionNode;
DirectiveDefinition: DirectiveDefinitionNode;
SchemaExtension: SchemaExtensionNode;
ScalarTypeExtension: ScalarTypeExtensionNode;
ObjectTypeExtension: ObjectTypeExtensionNode;
InterfaceTypeExtension: InterfaceTypeExtensionNode;
UnionTypeExtension: UnionTypeExtensionNode;
EnumTypeExtension: EnumTypeExtensionNode;
InputObjectTypeExtension: InputObjectTypeExtensionNode;
DirectiveDefinition: DirectiveDefinitionNode;
}
// Name
@@ -187,7 +189,7 @@ export interface DocumentNode {
readonly definitions: ReadonlyArray<DefinitionNode>;
}
export type DefinitionNode = ExecutableDefinitionNode | TypeSystemDefinitionNode; // experimental non-spec addition.
export type DefinitionNode = ExecutableDefinitionNode | TypeSystemDefinitionNode | TypeSystemExtensionNode;
export type ExecutableDefinitionNode = OperationDefinitionNode | FragmentDefinitionNode;
@@ -209,6 +211,7 @@ export interface VariableDefinitionNode {
readonly variable: VariableNode;
readonly type: TypeNode;
readonly defaultValue?: ValueNode;
readonly directives?: ReadonlyArray<DirectiveNode>;
}
export interface VariableNode {
@@ -372,16 +375,12 @@ export interface NonNullTypeNode {
// Type System Definition
export type TypeSystemDefinitionNode =
| SchemaDefinitionNode
| TypeDefinitionNode
| TypeExtensionNode
| DirectiveDefinitionNode;
export type TypeSystemDefinitionNode = SchemaDefinitionNode | TypeDefinitionNode | DirectiveDefinitionNode;
export interface SchemaDefinitionNode {
readonly kind: "SchemaDefinition";
readonly loc?: Location;
readonly directives: ReadonlyArray<DirectiveNode>;
readonly directives?: ReadonlyArray<DirectiveNode>;
readonly operationTypes: ReadonlyArray<OperationTypeDefinitionNode>;
}
@@ -484,6 +483,28 @@ export interface InputObjectTypeDefinitionNode {
readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
}
// Directive Definitions
export interface DirectiveDefinitionNode {
readonly kind: "DirectiveDefinition";
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
readonly locations: ReadonlyArray<NameNode>;
}
// Type System Extensions
export type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode;
export type SchemaExtensionNode = {
readonly kind: "SchemaExtension";
readonly loc?: Location;
readonly directives?: ReadonlyArray<DirectiveNode>;
readonly operationTypes?: ReadonlyArray<OperationTypeDefinitionNode>;
};
// Type Extensions
export type TypeExtensionNode =
@@ -541,14 +562,3 @@ export interface InputObjectTypeExtensionNode {
readonly directives?: ReadonlyArray<DirectiveNode>;
readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
}
// Directive Definitions
export interface DirectiveDefinitionNode {
readonly kind: "DirectiveDefinition";
readonly loc?: Location;
readonly description?: StringValueNode;
readonly name: NameNode;
readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
readonly locations: ReadonlyArray<NameNode>;
}
+1
View File
@@ -13,6 +13,7 @@ type _DirectiveLocation = {
FRAGMENT_DEFINITION: "FRAGMENT_DEFINITION";
FRAGMENT_SPREAD: "FRAGMENT_SPREAD";
INLINE_FRAGMENT: "INLINE_FRAGMENT";
VARIABLE_DEFINITION: "VARIABLE_DEFINITION";
// Type System Definitions
SCHEMA: "SCHEMA";
+21 -2
View File
@@ -66,9 +66,28 @@ export {
EnumTypeDefinitionNode,
EnumValueDefinitionNode,
InputObjectTypeDefinitionNode,
TypeExtensionNode,
ObjectTypeExtensionNode,
DirectiveDefinitionNode,
TypeSystemExtensionNode,
SchemaExtensionNode,
TypeExtensionNode,
ScalarTypeExtensionNode,
ObjectTypeExtensionNode,
InterfaceTypeExtensionNode,
UnionTypeExtensionNode,
EnumTypeExtensionNode,
InputObjectTypeExtensionNode,
} from "./ast";
export {
isDefinitionNode,
isExecutableDefinitionNode,
isSelectionNode,
isValueNode,
isTypeNode,
isTypeSystemDefinitionNode,
isTypeDefinitionNode,
isTypeSystemExtensionNode,
isTypeExtensionNode,
} from "./predicates";
export { DirectiveLocation, DirectiveLocationEnum } from "./directiveLocation";
+7 -4
View File
@@ -12,7 +12,6 @@ type _Kind = {
DOCUMENT: "Document";
OPERATION_DEFINITION: "OperationDefinition";
VARIABLE_DEFINITION: "VariableDefinition";
VARIABLE: "Variable";
SELECTION_SET: "SelectionSet";
FIELD: "Field";
ARGUMENT: "Argument";
@@ -23,6 +22,7 @@ type _Kind = {
FRAGMENT_DEFINITION: "FragmentDefinition";
// Values
VARIABLE: "Variable";
INT: "IntValue";
FLOAT: "FloatValue";
STRING: "StringValue";
@@ -56,6 +56,12 @@ type _Kind = {
ENUM_VALUE_DEFINITION: "EnumValueDefinition";
INPUT_OBJECT_TYPE_DEFINITION: "InputObjectTypeDefinition";
// Directive Definitions
DIRECTIVE_DEFINITION: "DirectiveDefinition";
// Type System Extensions
SCHEMA_EXTENSION: "SchemaExtension";
// Type Extensions
SCALAR_TYPE_EXTENSION: "ScalarTypeExtension";
OBJECT_TYPE_EXTENSION: "ObjectTypeExtension";
@@ -63,9 +69,6 @@ type _Kind = {
UNION_TYPE_EXTENSION: "UnionTypeExtension";
ENUM_TYPE_EXTENSION: "EnumTypeExtension";
INPUT_OBJECT_TYPE_EXTENSION: "InputObjectTypeExtension";
// Directive Definitions
DIRECTIVE_DEFINITION: "DirectiveDefinition";
};
/**
+13 -2
View File
@@ -19,7 +19,7 @@ export interface ParseOptions {
* specification.
*
* This option is provided to ease adoption of the final SDL specification
* and will be removed in a future major release.
* and will be removed in v16.
*/
allowLegacySDLEmptyFields?: boolean;
@@ -29,7 +29,7 @@ export interface ParseOptions {
* current specification.
*
* This option is provided to ease adoption of the final SDL specification
* and will be removed in a future major release.
* and will be removed in v16.
*/
allowLegacySDLImplementsInterfaces?: boolean;
@@ -50,6 +50,17 @@ export interface ParseOptions {
* future.
*/
experimentalFragmentVariables?: boolean;
/**
* EXPERIMENTAL:
*
* If enabled, the parser understands directives on variable definitions:
*
* query Foo($var: String = "abc" @variable_definition_directive) {
* ...
* }
*/
experimentalVariableDefinitionDirectives?: boolean;
}
/**
+19
View File
@@ -0,0 +1,19 @@
import { ASTNode } from "./ast";
export function isDefinitionNode(node: ASTNode): boolean;
export function isExecutableDefinitionNode(node: ASTNode): boolean;
export function isSelectionNode(node: ASTNode): boolean;
export function isValueNode(node: ASTNode): boolean;
export function isTypeNode(node: ASTNode): boolean;
export function isTypeSystemDefinitionNode(node: ASTNode): boolean;
export function isTypeDefinitionNode(node: ASTNode): boolean;
export function isTypeSystemExtensionNode(node: ASTNode): boolean;
export function isTypeExtensionNode(node: ASTNode): boolean;
+2 -2
View File
@@ -33,9 +33,9 @@ export type VisitFn<TAnyNode, TVisitedNode = TAnyNode> = (
parent: TAnyNode | ReadonlyArray<TAnyNode> | undefined,
// The key path to get to this node from the root node.
path: ReadonlyArray<string | number>,
// All nodes and Arrays visited before reaching this node.
// All nodes and Arrays visited before reaching parent of this node.
// These correspond to array indices in `path`.
// Note: ancestors includes arrays which contain the visited node.
// Note: ancestors includes arrays which contain the parent of visited node.
ancestors: ReadonlyArray<TAnyNode | ReadonlyArray<TAnyNode>>
) => any;
+36 -16
View File
@@ -16,6 +16,10 @@ import {
FieldNode,
FragmentDefinitionNode,
ValueNode,
ScalarTypeExtensionNode,
UnionTypeExtensionNode,
EnumTypeExtensionNode,
InputObjectTypeExtensionNode,
} from "../language/ast";
import { GraphQLSchema } from "./schema";
@@ -152,7 +156,7 @@ export function assertAbstractType(type: any): GraphQLAbstractType;
*/
export class GraphQLList<T extends GraphQLType> {
readonly ofType: T;
constructor(type: T);
constructor(ofType: T);
toString(): string;
toJSON(): string;
inspect(): string;
@@ -180,7 +184,7 @@ export class GraphQLList<T extends GraphQLType> {
*/
export class GraphQLNonNull<T extends GraphQLNullableType> {
readonly ofType: T;
constructor(type: T);
constructor(ofType: T);
toString(): string;
toJSON(): string;
inspect(): string;
@@ -256,30 +260,36 @@ export type Thunk<T> = (() => T) | T;
export class GraphQLScalarType {
name: string;
description: Maybe<string>;
astNode?: Maybe<ScalarTypeDefinitionNode>;
serialize: GraphQLScalarSerializer<any>;
parseValue: GraphQLScalarValueParser<any>;
parseLiteral: GraphQLScalarLiteralParser<any>;
astNode: Maybe<ScalarTypeDefinitionNode>;
extensionASTNodes: Maybe<ReadonlyArray<ScalarTypeExtensionNode>>;
constructor(config: GraphQLScalarTypeConfig<any, any>);
// Serializes an internal value to include in a response.
serialize(value: any): any;
// Parses an externally provided value to use as an input.
parseValue(value: any): any;
// Parses an externally provided literal value to use as an input.
parseLiteral(valueNode: ValueNode, variables?: Maybe<{ [key: string]: any }>): any;
toString(): string;
toJSON(): string;
inspect(): string;
}
export type GraphQLScalarSerializer<TExternal> = (value: any) => Maybe<TExternal>;
export type GraphQLScalarValueParser<TInternal> = (value: any) => Maybe<TInternal>;
export type GraphQLScalarLiteralParser<TInternal> = (
valueNode: ValueNode,
variables: Maybe<{ [key: string]: any }>
) => Maybe<TInternal>;
export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
name: string;
description?: Maybe<string>;
// Serializes an internal value to include in a response.
serialize: GraphQLScalarSerializer<TExternal>;
// Parses an externally provided value to use as an input.
parseValue?: GraphQLScalarValueParser<TInternal>;
// Parses an externally provided literal value to use as an input.
parseLiteral?: GraphQLScalarLiteralParser<TInternal>;
astNode?: Maybe<ScalarTypeDefinitionNode>;
serialize(value: any): Maybe<TExternal>;
parseValue?(value: any): Maybe<TInternal>;
parseLiteral?(valueNode: ValueNode, variables: Maybe<{ [key: string]: any }>): Maybe<TInternal>;
extensionASTNodes?: Maybe<ReadonlyArray<ScalarTypeExtensionNode>>;
}
/**
@@ -424,6 +434,8 @@ export interface GraphQLArgument {
astNode?: Maybe<InputValueDefinitionNode>;
}
export function isRequiredArgument(arg: GraphQLArgument): boolean;
export type GraphQLFieldMap<TSource, TContext> = {
[key: string]: GraphQLField<TSource, TContext>;
};
@@ -502,7 +514,8 @@ export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
export class GraphQLUnionType {
name: string;
description: Maybe<string>;
astNode?: Maybe<UnionTypeDefinitionNode>;
astNode: Maybe<UnionTypeDefinitionNode>;
extensionASTNodes: Maybe<ReadonlyArray<UnionTypeExtensionNode>>;
resolveType: Maybe<GraphQLTypeResolver<any, any>>;
constructor(config: GraphQLUnionTypeConfig<any, any>);
@@ -525,6 +538,7 @@ export interface GraphQLUnionTypeConfig<TSource, TContext> {
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
description?: Maybe<string>;
astNode?: Maybe<UnionTypeDefinitionNode>;
extensionASTNodes?: Maybe<ReadonlyArray<UnionTypeExtensionNode>>;
}
/**
@@ -552,6 +566,7 @@ export class GraphQLEnumType {
name: string;
description: Maybe<string>;
astNode: Maybe<EnumTypeDefinitionNode>;
extensionASTNodes: Maybe<ReadonlyArray<EnumTypeExtensionNode>>;
constructor(config: GraphQLEnumTypeConfig);
getValues(): GraphQLEnumValue[];
@@ -569,6 +584,7 @@ export interface GraphQLEnumTypeConfig {
values: GraphQLEnumValueConfigMap;
description?: Maybe<string>;
astNode?: Maybe<EnumTypeDefinitionNode>;
extensionASTNodes?: Maybe<ReadonlyArray<EnumTypeExtensionNode>>;
}
export type GraphQLEnumValueConfigMap = { [key: string]: GraphQLEnumValueConfig };
@@ -613,6 +629,7 @@ export class GraphQLInputObjectType {
name: string;
description: Maybe<string>;
astNode: Maybe<InputObjectTypeDefinitionNode>;
extensionASTNodes: Maybe<ReadonlyArray<InputObjectTypeExtensionNode>>;
constructor(config: GraphQLInputObjectTypeConfig);
getFields(): GraphQLInputFieldMap;
toString(): string;
@@ -625,6 +642,7 @@ export interface GraphQLInputObjectTypeConfig {
fields: Thunk<GraphQLInputFieldConfigMap>;
description?: Maybe<string>;
astNode?: Maybe<InputObjectTypeDefinitionNode>;
extensionASTNodes?: Maybe<ReadonlyArray<InputObjectTypeExtensionNode>>;
}
export interface GraphQLInputFieldConfig {
@@ -646,4 +664,6 @@ export interface GraphQLInputField {
astNode?: Maybe<InputValueDefinitionNode>;
}
export function isRequiredInputField(field: GraphQLInputField): boolean;
export type GraphQLInputFieldMap = { [key: string]: GraphQLInputField };
+5
View File
@@ -25,6 +25,8 @@ export {
isWrappingType,
isNullableType,
isNamedType,
isRequiredArgument,
isRequiredInputField,
// Assertions
assertType,
assertScalarType,
@@ -92,6 +94,9 @@ export {
GraphQLScalarTypeConfig,
GraphQLTypeResolver,
GraphQLUnionTypeConfig,
GraphQLScalarSerializer,
GraphQLScalarValueParser,
GraphQLScalarLiteralParser,
} from "./definition";
export {
+4 -3
View File
@@ -1,7 +1,7 @@
import Maybe from "../tsutils/Maybe";
import { GraphQLObjectType } from "./definition";
import { GraphQLType, GraphQLNamedType, GraphQLAbstractType } from "./definition";
import { SchemaDefinitionNode } from "../language/ast";
import { SchemaDefinitionNode, SchemaExtensionNode } from "../language/ast";
import { GraphQLDirective } from "./directives";
/**
@@ -37,6 +37,7 @@ export function isSchema(schema: any): schema is GraphQLSchema;
*/
export class GraphQLSchema {
astNode: Maybe<SchemaDefinitionNode>;
extensionASTNodes: Maybe<ReadonlyArray<SchemaExtensionNode>>;
constructor(config: GraphQLSchemaConfig);
@@ -70,8 +71,7 @@ export interface GraphQLSchemaValidationOptions {
* in this list valid, even if they do not adhere to the specification's
* schema validation rules.
*
* This option is provided to ease adoption and may be removed in a future
* major release.
* This option is provided to ease adoption and will be removed in v15.
*/
allowedLegacyNames?: Maybe<ReadonlyArray<string>>;
}
@@ -83,4 +83,5 @@ export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
types?: Maybe<GraphQLNamedType[]>;
directives?: Maybe<GraphQLDirective[]>;
astNode?: Maybe<SchemaDefinitionNode>;
extensionASTNodes?: Maybe<ReadonlyArray<SchemaExtensionNode>>;
}
+17 -2
View File
@@ -7,8 +7,10 @@ import {
NamedTypeNode,
DirectiveDefinitionNode,
FieldDefinitionNode,
InputValueDefinitionNode,
EnumValueDefinitionNode,
} from "../language/ast";
import { GraphQLNamedType, GraphQLFieldConfig } from "../type/definition";
import { GraphQLNamedType, GraphQLFieldConfig, GraphQLInputField, GraphQLEnumValueConfig } from "../type/definition";
import { GraphQLDirective } from "../type/directives";
import { Source } from "../language/source";
import { GraphQLSchema, GraphQLSchemaValidationOptions } from "../type/schema";
@@ -20,10 +22,18 @@ interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {
* Descriptions are defined as preceding string literals, however an older
* experimental version of the SDL supported preceding comments as
* descriptions. Set to true to enable this deprecated behavior.
* This option is provided to ease adoption and will be removed in v16.
*
* Default: false
*/
commentDescriptions?: boolean;
/**
* Set to true to assume the SDL is valid.
*
* Default: false
*/
assumeValidSDL?: boolean;
}
/**
@@ -42,7 +52,7 @@ interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {
* Provide true to use preceding comments as the description.
*
*/
export function buildASTSchema(ast: DocumentNode, options?: BuildSchemaOptions): GraphQLSchema;
export function buildASTSchema(documentAST: DocumentNode, options?: BuildSchemaOptions): GraphQLSchema;
type TypeDefinitionsMap = { [key: string]: TypeDefinitionNode };
type TypeResolver = (typeRef: NamedTypeNode) => GraphQLNamedType;
@@ -57,10 +67,15 @@ export class ASTDefinitionBuilder {
buildDirective(directiveNode: DirectiveDefinitionNode): GraphQLDirective;
buildField(field: FieldDefinitionNode): GraphQLFieldConfig<any, any>;
buildInputField(value: InputValueDefinitionNode): GraphQLInputField;
buildEnumValue(value: EnumValueDefinitionNode): GraphQLEnumValueConfig;
}
/**
* Given an ast node, returns its string description.
* @deprecated: provided to ease adoption and will be removed in v16.
*
* Accepts options as a second argument:
*
+1 -1
View File
@@ -1,4 +1,4 @@
import { GraphQLError } from "../error";
import { GraphQLError } from "../error/GraphQLError";
import { ASTNode } from "../language/ast";
import { GraphQLInputType } from "../type/definition";
+8
View File
@@ -7,10 +7,18 @@ interface Options extends GraphQLSchemaValidationOptions {
* Descriptions are defined as preceding string literals, however an older
* experimental version of the SDL supported preceding comments as
* descriptions. Set to true to enable this deprecated behavior.
* This option is provided to ease adoption and will be removed in v16.
*
* Default: false
*/
commentDescriptions?: boolean;
/**
* Set to true to assume the SDL is valid.
*
* Default: false
*/
assumeValidSDL?: boolean;
}
/**
+6 -6
View File
@@ -12,7 +12,7 @@ import { GraphQLDirective } from "../type/directives";
import { GraphQLSchema } from "../type/schema";
import { DirectiveLocationEnum } from "../language/directiveLocation";
export const BreakingChangeType : _BreakingChangeType;
export const BreakingChangeType: _BreakingChangeType;
// @internal
type _BreakingChangeType = {
@@ -24,13 +24,13 @@ type _BreakingChangeType = {
VALUE_REMOVED_FROM_ENUM: "VALUE_REMOVED_FROM_ENUM";
ARG_REMOVED: "ARG_REMOVED";
ARG_CHANGED_KIND: "ARG_CHANGED_KIND";
NON_NULL_ARG_ADDED: "NON_NULL_ARG_ADDED";
NON_NULL_INPUT_FIELD_ADDED: "NON_NULL_INPUT_FIELD_ADDED";
REQUIRED_ARG_ADDED: "REQUIRED_ARG_ADDED";
REQUIRED_INPUT_FIELD_ADDED: "REQUIRED_INPUT_FIELD_ADDED";
INTERFACE_REMOVED_FROM_OBJECT: "INTERFACE_REMOVED_FROM_OBJECT";
DIRECTIVE_REMOVED: "DIRECTIVE_REMOVED";
DIRECTIVE_ARG_REMOVED: "DIRECTIVE_ARG_REMOVED";
DIRECTIVE_LOCATION_REMOVED: "DIRECTIVE_LOCATION_REMOVED";
NON_NULL_DIRECTIVE_ARG_ADDED: "NON_NULL_DIRECTIVE_ARG_ADDED";
REQUIRED_DIRECTIVE_ARG_ADDED: "REQUIRED_DIRECTIVE_ARG_ADDED";
};
export const DangerousChangeType: _DangerousChangeType;
@@ -41,8 +41,8 @@ type _DangerousChangeType = {
VALUE_ADDED_TO_ENUM: "VALUE_ADDED_TO_ENUM";
INTERFACE_ADDED_TO_OBJECT: "INTERFACE_ADDED_TO_OBJECT";
TYPE_ADDED_TO_UNION: "TYPE_ADDED_TO_UNION";
NULLABLE_INPUT_FIELD_ADDED: "NULLABLE_INPUT_FIELD_ADDED";
NULLABLE_ARG_ADDED: "NULLABLE_ARG_ADDED";
OPTIONAL_INPUT_FIELD_ADDED: "OPTIONAL_INPUT_FIELD_ADDED";
OPTIONAL_ARG_ADDED: "OPTIONAL_ARG_ADDED";
};
export interface BreakingChange {
+11
View File
@@ -0,0 +1,11 @@
import { GraphQLSchema } from "../type/schema";
import { OperationDefinitionNode, OperationTypeDefinitionNode } from "../language/ast";
import { GraphQLObjectType } from "../type/definition";
/**
* Extracts the root type of the operation from the schema.
*/
export function getOperationRootType(
schema: GraphQLSchema,
operation: OperationDefinitionNode | OperationTypeDefinitionNode
): GraphQLObjectType;
+14 -4
View File
@@ -1,7 +1,7 @@
// The GraphQL query recommended for a full schema introspection.
export {
getIntrospectionQuery,
// Deprecated, use getIntrospectionQuery()
// @deprecated, use getIntrospectionQuery() - will be removed in v15
introspectionQuery,
} from "./introspectionQuery";
@@ -33,6 +33,9 @@ export {
// Gets the target Operation from a Document
export { getOperationAST } from "./getOperationAST";
// Gets the Type for the target Operation AST.
export { getOperationRootType } from "./getOperationRootType";
// Convert a GraphQLSchema to an IntrospectionQuery
export { introspectionFromSchema } from "./introspectionFromSchema";
@@ -40,7 +43,14 @@ export { introspectionFromSchema } from "./introspectionFromSchema";
export { buildClientSchema } from "./buildClientSchema";
// Build a GraphQLSchema from GraphQL Schema language.
export { buildASTSchema, buildSchema, getDescription, BuildSchemaOptions } from "./buildASTSchema";
export {
buildASTSchema,
buildSchema,
// @deprecated: Get the description from a schema AST node and supports legacy
// syntax for specifying descriptions - will be removed in v16
getDescription,
BuildSchemaOptions,
} from "./buildASTSchema";
// Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST.
export { extendSchema } from "./extendSchema";
@@ -70,10 +80,10 @@ export { TypeInfo } from "./TypeInfo";
// Coerces a JavaScript value to a GraphQL type, or produces errors.
export { coerceValue } from "./coerceValue";
// @deprecated use coerceValue
// @deprecated use coerceValue - will be removed in v15
export { isValidJSValue } from "./isValidJSValue";
// Determine if AST values adhere to a GraphQL type.
// @deprecated use validation - will be removed in v15
export { isValidLiteralValue } from "./isValidLiteralValue";
// Concatenates multiple AST together.
+1 -1
View File
@@ -10,4 +10,4 @@ import { IntrospectionQuery, IntrospectionOptions } from "./introspectionQuery";
* This is the inverse of buildClientSchema. The primary use case is outside
* of the server context, for instance when doing schema comparisons.
*/
export function introspectionFromSchema(schema: GraphQLSchema, options: IntrospectionOptions): IntrospectionQuery;
export function introspectionFromSchema(schema: GraphQLSchema, options?: IntrospectionOptions): IntrospectionQuery;
+5
View File
@@ -9,6 +9,11 @@ export interface IntrospectionOptions {
export function getIntrospectionQuery(options?: IntrospectionOptions): string;
/**
* Deprecated, call getIntrospectionQuery directly.
*
* This function will be removed in v15
*/
export const introspectionQuery: string;
export interface IntrospectionQuery {
+2
View File
@@ -2,5 +2,7 @@ import { GraphQLInputType } from "../type/definition";
/**
* Deprecated. Use coerceValue() directly for richer information.
*
* This function will be removed in v15
*/
export function isValidJSValue(value: any, type: GraphQLInputType): string[];
+2
View File
@@ -6,5 +6,7 @@ import { GraphQLInputType } from "../type/definition";
* Utility which determines if a value literal node is valid for an input type.
*
* Deprecated. Rely on validation for documents containing literal values.
*
* This function will be removed in v15
*/
export function isValidLiteralValue(type: GraphQLInputType, valueNode: ValueNode): ReadonlyArray<GraphQLError>;
+8
View File
@@ -2,6 +2,14 @@ import { GraphQLSchema } from "../type/schema";
import { GraphQLType, GraphQLNamedType } from "../type/definition";
export interface Options {
/**
* Descriptions are defined as preceding string literals, however an older
* experimental version of the SDL supported preceding comments as
* descriptions. Set to true to enable this deprecated behavior.
* This option is provided to ease adoption and will be removed in v16.
*
* Default: false
*/
commentDescriptions?: boolean;
}
+19 -4
View File
@@ -18,6 +18,7 @@ import {
} from "../type/definition";
import { GraphQLDirective } from "../type/directives";
import { TypeInfo } from "../utilities/TypeInfo";
import { ASTVisitor } from "../language/visitor";
type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode;
type VariableUsage = {
@@ -31,16 +32,28 @@ type VariableUsage = {
* allowing access to commonly useful contextual information from within a
* validation rule.
*/
export default class ValidationContext {
constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo);
export class ASTValidationContext {
constructor(ast: DocumentNode);
reportError(error: GraphQLError): undefined;
getErrors(): ReadonlyArray<GraphQLError>;
getSchema(): GraphQLSchema;
getDocument(): DocumentNode;
}
export class SDLValidationContext extends ASTValidationContext {
constructor(ast: DocumentNode, schema?: Maybe<GraphQLSchema>);
getSchema(): Maybe<GraphQLSchema>;
}
export type SDLValidationRule = (context: SDLValidationContext) => ASTVisitor;
export class ValidationContext extends ASTValidationContext {
constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo);
getSchema(): GraphQLSchema;
getFragment(name: string): Maybe<FragmentDefinitionNode>;
@@ -66,3 +79,5 @@ export default class ValidationContext {
getArgument(): Maybe<GraphQLArgument>;
}
export type ValidationRule = (context: ValidationContext) => ASTVisitor;
+2 -6
View File
@@ -1,7 +1,6 @@
export { validate } from "./validate";
import ValidationContext from "./ValidationContext";
export { ValidationContext };
export { ValidationContext } from "./ValidationContext";
export { specifiedRules } from "./specifiedRules";
@@ -45,7 +44,7 @@ export { OverlappingFieldsCanBeMerged as OverlappingFieldsCanBeMergedRule } from
export { PossibleFragmentSpreads as PossibleFragmentSpreadsRule } from "./rules/PossibleFragmentSpreads";
// Spec Section: "Argument Optionality"
export { ProvidedNonNullArguments as ProvidedNonNullArgumentsRule } from "./rules/ProvidedNonNullArguments";
export { ProvidedRequiredArguments as ProvidedRequiredArgumentsRule } from "./rules/ProvidedRequiredArguments";
// Spec Section: "Leaf Field Selections"
export { ScalarLeafs as ScalarLeafsRule } from "./rules/ScalarLeafs";
@@ -77,8 +76,5 @@ export { ValuesOfCorrectType as ValuesOfCorrectTypeRule } from "./rules/ValuesOf
// Spec Section: "Variables are Input Types"
export { VariablesAreInputTypes as VariablesAreInputTypesRule } from "./rules/VariablesAreInputTypes";
// Spec Section: "Variables Default Value Is Allowed"
export { VariablesDefaultValueAllowed as VariablesDefaultValueAllowedRule } from "./rules/VariablesDefaultValueAllowed";
// Spec Section: "All Variable Usages Are Allowed"
export { VariablesInAllowedPosition as VariablesInAllowedPositionRule } from "./rules/VariablesInAllowedPosition";
+2 -2
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ASTValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function nonExecutableDefinitionMessage(defName: string): string;
@@ -9,4 +9,4 @@ export function nonExecutableDefinitionMessage(defName: string): string;
* A GraphQL document is only valid for execution if all definitions are either
* operation or fragment definitions.
*/
export function ExecutableDefinitions(context: ValidationContext): ASTVisitor;
export function ExecutableDefinitions(context: ASTValidationContext): ASTVisitor;
+1 -1
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
/**
@@ -1,10 +1,9 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
import { GraphQLType } from "../../type/definition";
export function inlineFragmentOnNonCompositeErrorMessage(type: GraphQLType): string;
export function inlineFragmentOnNonCompositeErrorMessage(type: string): string;
export function fragmentOnNonCompositeErrorMessage(fragName: string, type: GraphQLType): string;
export function fragmentOnNonCompositeErrorMessage(fragName: string, type: string): string;
/**
* Fragments on composite type
+4 -1
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext, SDLValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function unknownArgMessage(
@@ -21,3 +21,6 @@ export function unknownDirectiveArgMessage(
* that field.
*/
export function KnownArgumentNames(context: ValidationContext): ASTVisitor;
// @internal
export function KnownArgumentNamesOnDirectives(context: ValidationContext | SDLValidationContext): ASTVisitor;
+2 -2
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext, SDLValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function unknownDirectiveMessage(directiveName: string): string;
@@ -11,4 +11,4 @@ export function misplacedDirectiveMessage(directiveName: string, location: strin
* A GraphQL document is only valid if all `@directives` are known by the
* schema and legally positioned.
*/
export function KnownDirectives(context: ValidationContext): ASTVisitor;
export function KnownDirectives(context: ValidationContext | SDLValidationContext): ASTVisitor;
+1 -1
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function unknownFragmentMessage(fragName: string): string;
+1 -1
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function unknownTypeMessage(typeName: string, suggestedTypes: Array<string>): string;
+2 -2
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ASTValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function anonOperationNotAloneMessage(): string;
@@ -9,4 +9,4 @@ export function anonOperationNotAloneMessage(): string;
* A GraphQL document is only valid if when it contains an anonymous operation
* (the query short-hand) that it contains only that one operation definition.
*/
export function LoneAnonymousOperation(context: ValidationContext): ASTVisitor;
export function LoneAnonymousOperation(context: ASTValidationContext): ASTVisitor;
@@ -0,0 +1,13 @@
import { SDLValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function schemaDefinitionNotAloneMessage(): string;
export function canNotDefineSchemaWithinExtensionMessage(): string;
/**
* Lone Schema definition
*
* A GraphQL document is only valid if it contains only one schema definition.
*/
export function LoneSchemaDefinition(context: SDLValidationContext): ASTVisitor;
+1 -1
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function cycleErrorMessage(fragName: string, spreadNames: Array<string>): string;
+1 -1
View File
@@ -1,5 +1,5 @@
import Maybe from "../../tsutils/Maybe";
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function undefinedVarMessage(varName: string, opName: Maybe<string>): string;
+1 -1
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function unusedFragMessage(fragName: string): string;
+1 -1
View File
@@ -1,5 +1,5 @@
import Maybe from "../../tsutils/Maybe";
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function unusedVariableMessage(varName: string, opName: Maybe<string>): string;
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function fieldsConflictMessage(responseName: string, reason: ConflictReasonMessage): string;
@@ -1,10 +1,9 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
import { GraphQLType } from "../../type/definition";
export function typeIncompatibleSpreadMessage(fragName: string, parentType: GraphQLType, fragType: GraphQLType): string;
export function typeIncompatibleSpreadMessage(fragName: string, parentType: string, fragType: string): string;
export function typeIncompatibleAnonSpreadMessage(parentType: GraphQLType, fragType: GraphQLType): string;
export function typeIncompatibleAnonSpreadMessage(parentType: string, fragType: string): string;
/**
* Possible fragment spread
@@ -1,15 +0,0 @@
import ValidationContext from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
import { GraphQLType } from "../../type/definition";
export function missingFieldArgMessage(fieldName: string, argName: string, type: GraphQLType): string;
export function missingDirectiveArgMessage(directiveName: string, argName: string, type: GraphQLType): string;
/**
* Provided required arguments
*
* A field or directive is only valid if all required (non-null) field arguments
* have been provided.
*/
export function ProvidedNonNullArguments(context: ValidationContext): ASTVisitor;
@@ -0,0 +1,17 @@
import { ValidationContext, SDLValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function missingFieldArgMessage(fieldName: string, argName: string, type: string): string;
export function missingDirectiveArgMessage(directiveName: string, argName: string, type: string): string;
/**
* Provided required arguments
*
* A field or directive is only valid if all required (non-null without a
* default value) field arguments have been provided.
*/
export function ProvidedRequiredArguments(context: ValidationContext): ASTVisitor;
// @internal
export function ProvidedRequiredArgumentsOnDirectives(context: ValidationContext | SDLValidationContext): ASTVisitor;
+3 -4
View File
@@ -1,10 +1,9 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
import { GraphQLType } from "../../type/definition";
export function noSubselectionAllowedMessage(fieldName: string, type: GraphQLType): string;
export function noSubselectionAllowedMessage(fieldName: string, type: string): string;
export function requiredSubselectionMessage(fieldName: string, type: GraphQLType): string;
export function requiredSubselectionMessage(fieldName: string, type: string): string;
/**
* Scalar leafs
@@ -1,5 +1,5 @@
import Maybe from "../../tsutils/Maybe";
import ValidationContext from "../ValidationContext";
import { ASTValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function singleFieldOnlyMessage(name: Maybe<string>): string;
@@ -9,4 +9,4 @@ export function singleFieldOnlyMessage(name: Maybe<string>): string;
*
* A GraphQL subscription is valid only if it contains a single root field.
*/
export function SingleFieldSubscriptions(context: ValidationContext): ASTVisitor;
export function SingleFieldSubscriptions(context: ASTValidationContext): ASTVisitor;
+2 -2
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ASTValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function duplicateArgMessage(argName: string): string;
@@ -9,4 +9,4 @@ export function duplicateArgMessage(argName: string): string;
* A GraphQL field or directive is only valid if all supplied arguments are
* uniquely named.
*/
export function UniqueArgumentNames(context: ValidationContext): ASTVisitor;
export function UniqueArgumentNames(context: ASTValidationContext): ASTVisitor;
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ASTValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function duplicateDirectiveMessage(directiveName: string): string;
@@ -9,4 +9,4 @@ export function duplicateDirectiveMessage(directiveName: string): string;
* A GraphQL document is only valid if all directives at a given location
* are uniquely named.
*/
export function UniqueDirectivesPerLocation(context: ValidationContext): ASTVisitor;
export function UniqueDirectivesPerLocation(context: ASTValidationContext): ASTVisitor;
+2 -2
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ASTValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function duplicateFragmentNameMessage(fragName: string): string;
@@ -8,4 +8,4 @@ export function duplicateFragmentNameMessage(fragName: string): string;
*
* A GraphQL document is only valid if all defined fragments have unique names.
*/
export function UniqueFragmentNames(context: ValidationContext): ASTVisitor;
export function UniqueFragmentNames(context: ASTValidationContext): ASTVisitor;
+2 -2
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ASTValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function duplicateInputFieldMessage(fieldName: string): string;
@@ -9,4 +9,4 @@ export function duplicateInputFieldMessage(fieldName: string): string;
* A GraphQL input object value is only valid if all supplied fields are
* uniquely named.
*/
export function UniqueInputFieldNames(context: ValidationContext): ASTVisitor;
export function UniqueInputFieldNames(context: ASTValidationContext): ASTVisitor;
+2 -2
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ASTValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function duplicateOperationNameMessage(operationName: string): string;
@@ -8,4 +8,4 @@ export function duplicateOperationNameMessage(operationName: string): string;
*
* A GraphQL document is only valid if all defined operations have unique names.
*/
export function UniqueOperationNames(context: ValidationContext): ASTVisitor;
export function UniqueOperationNames(context: ASTValidationContext): ASTVisitor;
+2 -2
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ASTValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function duplicateVariableMessage(variableName: string): string;
@@ -8,4 +8,4 @@ export function duplicateVariableMessage(variableName: string): string;
*
* A GraphQL operation is only valid if all its variables are uniquely named.
*/
export function UniqueVariableNames(context: ValidationContext): ASTVisitor;
export function UniqueVariableNames(context: ASTValidationContext): ASTVisitor;
+1 -1
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function badValueMessage(typeName: string, valueName: string, message?: string): string;
+1 -1
View File
@@ -1,4 +1,4 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
export function nonInputTypeOnVarMessage(variableName: string, typeName: string): string;
@@ -1,13 +0,0 @@
import ValidationContext from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
import { GraphQLType } from "../../type/definition";
export function defaultForRequiredVarMessage(varName: string, type: GraphQLType, guessType: GraphQLType): string;
/**
* Variable's default value is allowed
*
* A GraphQL document is only valid if all variable default values are allowed
* due to a variable not being required.
*/
export function VariablesDefaultValueAllowed(context: ValidationContext): ASTVisitor;
@@ -1,8 +1,7 @@
import ValidationContext from "../ValidationContext";
import { ValidationContext } from "../ValidationContext";
import { ASTVisitor } from "../../language/visitor";
import { GraphQLType } from "../../type/definition";
export function badVarPosMessage(varName: string, varType: GraphQLType, expectedType: GraphQLType): string;
export function badVarPosMessage(varName: string, varType: string, expectedType: string): string;
/**
* Variables passed to field arguments conform to type
+9 -7
View File
@@ -1,3 +1,5 @@
import { ValidationRule, SDLValidationRule } from "./ValidationContext";
// Spec Section: "Executable Definitions"
import { ExecutableDefinitions } from "./rules/ExecutableDefinitions";
@@ -65,10 +67,7 @@ import { UniqueArgumentNames } from "./rules/UniqueArgumentNames";
import { ValuesOfCorrectType } from "./rules/ValuesOfCorrectType";
// Spec Section: "Argument Optionality"
import { ProvidedNonNullArguments } from "./rules/ProvidedNonNullArguments";
// Spec Section: "Variables Default Value Is Allowed"
import { VariablesDefaultValueAllowed } from "./rules/VariablesDefaultValueAllowed";
import { ProvidedRequiredArguments } from "./rules/ProvidedRequiredArguments";
// Spec Section: "All Variable Usages Are Allowed"
import { VariablesInAllowedPosition } from "./rules/VariablesInAllowedPosition";
@@ -79,12 +78,15 @@ import { OverlappingFieldsCanBeMerged } from "./rules/OverlappingFieldsCanBeMerg
// Spec Section: "Input Object Field Uniqueness"
import { UniqueInputFieldNames } from "./rules/UniqueInputFieldNames";
import ValidationContext from "./ValidationContext";
/**
* This set includes all validation rules defined by the GraphQL spec.
*
* The order of the rules in this list has been adjusted to lead to the
* most clear output when encountering multiple validation errors.
*/
export const specifiedRules: Array<(context: ValidationContext) => any>;
export const specifiedRules: ReadonlyArray<ValidationRule>;
import { LoneSchemaDefinition } from "./rules/LoneSchemaDefinition";
// @internal
export const specifiedSDLRules: ReadonlyArray<SDLValidationRule>;
+19 -2
View File
@@ -2,6 +2,7 @@ import { GraphQLError } from "../error";
import { DocumentNode } from "../language/ast";
import { GraphQLSchema } from "../type/schema";
import { TypeInfo } from "../utilities/TypeInfo";
import { ValidationRule } from "./ValidationContext";
/**
* Implements the "Validation" section of the spec.
@@ -21,7 +22,23 @@ import { TypeInfo } from "../utilities/TypeInfo";
*/
export function validate(
schema: GraphQLSchema,
ast: DocumentNode,
rules?: ReadonlyArray<any>,
documentAST: DocumentNode,
rules?: ReadonlyArray<ValidationRule>,
typeInfo?: TypeInfo
): ReadonlyArray<GraphQLError>;
/**
* Utility function which asserts a SDL document is valid by throwing an error
* if it is invalid.
*
* @internal
*/
export function assertValidSDL(documentAST: DocumentNode): undefined;
/**
* Utility function which asserts a SDL document is valid by throwing an error
* if it is invalid.
*
* @internal
*/
export function assertValidSDLExtension(documentAST: DocumentNode, schema: GraphQLSchema): undefined;