mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
update graphql/validation/* -> v0.13.2.
https://github.com/graphql/graphql-js/tree/v0.13.2/src/validation
This commit is contained in:
parent
2a02f2f7ee
commit
a3021f8040
63
types/graphql/validation/ValidationContext.d.ts
vendored
Normal file
63
types/graphql/validation/ValidationContext.d.ts
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
import { GraphQLError } from "../error";
|
||||
import {
|
||||
DocumentNode,
|
||||
OperationDefinitionNode,
|
||||
VariableNode,
|
||||
SelectionSetNode,
|
||||
FragmentSpreadNode,
|
||||
FragmentDefinitionNode,
|
||||
} from "../language/ast";
|
||||
import { GraphQLSchema } from "../type/schema";
|
||||
import {
|
||||
GraphQLInputType,
|
||||
GraphQLOutputType,
|
||||
GraphQLCompositeType,
|
||||
GraphQLField,
|
||||
GraphQLArgument,
|
||||
} from "../type/definition";
|
||||
import { GraphQLDirective } from "../type/directives";
|
||||
import { TypeInfo } from "../utilities/TypeInfo";
|
||||
|
||||
type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode;
|
||||
type VariableUsage = { node: VariableNode; type: GraphQLInputType | void };
|
||||
|
||||
/**
|
||||
* An instance of this class is passed as the "this" context to all validators,
|
||||
* allowing access to commonly useful contextual information from within a
|
||||
* validation rule.
|
||||
*/
|
||||
export default class ValidationContext {
|
||||
constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo);
|
||||
|
||||
reportError(error: GraphQLError): undefined;
|
||||
|
||||
getErrors(): ReadonlyArray<GraphQLError>;
|
||||
|
||||
getSchema(): GraphQLSchema;
|
||||
|
||||
getDocument(): DocumentNode;
|
||||
|
||||
getFragment(name: string): FragmentDefinitionNode | void;
|
||||
|
||||
getFragmentSpreads(node: SelectionSetNode): ReadonlyArray<FragmentSpreadNode>;
|
||||
|
||||
getRecursivelyReferencedFragments(operation: OperationDefinitionNode): ReadonlyArray<FragmentDefinitionNode>;
|
||||
|
||||
getVariableUsages(node: NodeWithSelectionSet): ReadonlyArray<VariableUsage>;
|
||||
|
||||
getRecursiveVariableUsages(operation: OperationDefinitionNode): ReadonlyArray<VariableUsage>;
|
||||
|
||||
getType(): GraphQLOutputType | void;
|
||||
|
||||
getParentType(): GraphQLCompositeType | void;
|
||||
|
||||
getInputType(): GraphQLInputType | void;
|
||||
|
||||
getParentInputType(): GraphQLInputType | void;
|
||||
|
||||
getFieldDef(): GraphQLField<any, any> | void;
|
||||
|
||||
getDirective(): GraphQLDirective | void;
|
||||
|
||||
getArgument(): GraphQLArgument | void;
|
||||
}
|
||||
18
types/graphql/validation/index.d.ts
vendored
18
types/graphql/validation/index.d.ts
vendored
@ -1,12 +1,10 @@
|
||||
export { validate, ValidationContext } from "./validate";
|
||||
export { validate } from "./validate";
|
||||
|
||||
import ValidationContext from "./ValidationContext";
|
||||
export { ValidationContext };
|
||||
|
||||
export { specifiedRules } from "./specifiedRules";
|
||||
|
||||
// Spec Section: "Argument Values Type Correctness"
|
||||
export { ArgumentsOfCorrectType as ArgumentsOfCorrectTypeRule } from "./rules/ArgumentsOfCorrectType";
|
||||
|
||||
// Spec Section: "Variable Default Values Are Correctly Typed"
|
||||
export { DefaultValuesOfCorrectType as DefaultValuesOfCorrectTypeRule } from "./rules/DefaultValuesOfCorrectType";
|
||||
|
||||
// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types"
|
||||
export { FieldsOnCorrectType as FieldsOnCorrectTypeRule } from "./rules/FieldsOnCorrectType";
|
||||
|
||||
@ -73,8 +71,14 @@ export { UniqueOperationNames as UniqueOperationNamesRule } from "./rules/Unique
|
||||
// Spec Section: "Variable Uniqueness"
|
||||
export { UniqueVariableNames as UniqueVariableNamesRule } from "./rules/UniqueVariableNames";
|
||||
|
||||
// Spec Section: "Values Type Correctness"
|
||||
export { ValuesOfCorrectType as ValuesOfCorrectTypeRule } from "./rules/ValuesOfCorrectType";
|
||||
|
||||
// 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";
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
import { ValidationContext } from "../index";
|
||||
|
||||
/**
|
||||
* Argument values of correct type
|
||||
*
|
||||
* A GraphQL document is only valid if all field argument literal values are
|
||||
* of the type expected by their position.
|
||||
*/
|
||||
export function ArgumentsOfCorrectType(context: ValidationContext): any;
|
||||
@ -1,9 +0,0 @@
|
||||
import { ValidationContext } from "../index";
|
||||
|
||||
/**
|
||||
* Variable default values of correct type
|
||||
*
|
||||
* A GraphQL document is only valid if all variable default values are of the
|
||||
* type expected by their definition.
|
||||
*/
|
||||
export function DefaultValuesOfCorrectType(context: ValidationContext): any;
|
||||
12
types/graphql/validation/rules/ExecutableDefinitions.d.ts
vendored
Normal file
12
types/graphql/validation/rules/ExecutableDefinitions.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function nonExecutableDefinitionMessage(defName: string): string;
|
||||
|
||||
/**
|
||||
* Executable definitions
|
||||
*
|
||||
* A GraphQL document is only valid for execution if all definitions are either
|
||||
* operation or fragment definitions.
|
||||
*/
|
||||
export function ExecutableDefinitions(context: ValidationContext): ASTVisitor;
|
||||
@ -1,4 +1,5 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
/**
|
||||
* Fields on correct type
|
||||
@ -6,4 +7,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL document is only valid if all fields selected are defined by the
|
||||
* parent type, or are an allowed meta field such as __typename.
|
||||
*/
|
||||
export function FieldsOnCorrectType(context: ValidationContext): any;
|
||||
export function FieldsOnCorrectType(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,10 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
import { GraphQLType } from "../../type/definition";
|
||||
|
||||
export function inlineFragmentOnNonCompositeErrorMessage(type: GraphQLType): string;
|
||||
|
||||
export function fragmentOnNonCompositeErrorMessage(fragName: string, type: GraphQLType): string;
|
||||
|
||||
/**
|
||||
* Fragments on composite type
|
||||
@ -7,4 +13,4 @@ import { ValidationContext } from "../index";
|
||||
* can only be spread into a composite type (object, interface, or union), the
|
||||
* type condition must also be a composite type.
|
||||
*/
|
||||
export function FragmentsOnCompositeTypes(context: ValidationContext): any;
|
||||
export function FragmentsOnCompositeTypes(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,18 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function unknownArgMessage(
|
||||
argName: string,
|
||||
fieldName: string,
|
||||
typeName: string,
|
||||
suggestedArgs: Array<string>
|
||||
): string;
|
||||
|
||||
export function unknownDirectiveArgMessage(
|
||||
argName: string,
|
||||
directiveName: string,
|
||||
suggestedArgs: Array<string>
|
||||
): string;
|
||||
|
||||
/**
|
||||
* Known argument names
|
||||
@ -6,4 +20,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL field is only valid if all supplied arguments are defined by
|
||||
* that field.
|
||||
*/
|
||||
export function KnownArgumentNames(context: ValidationContext): any;
|
||||
export function KnownArgumentNames(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function unknownDirectiveMessage(directiveName: string): string;
|
||||
|
||||
export function misplacedDirectiveMessage(directiveName: string, location: string): string;
|
||||
|
||||
/**
|
||||
* Known directives
|
||||
@ -6,4 +11,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL document is only valid if all `@directives` are known by the
|
||||
* schema and legally positioned.
|
||||
*/
|
||||
export function KnownDirectives(context: ValidationContext): any;
|
||||
export function KnownDirectives(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function unknownFragmentMessage(fragName: string): string;
|
||||
|
||||
/**
|
||||
* Known fragment names
|
||||
@ -6,4 +9,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL document is only valid if all `...Fragment` fragment spreads refer
|
||||
* to fragments defined in the same document.
|
||||
*/
|
||||
export function KnownFragmentNames(context: ValidationContext): any;
|
||||
export function KnownFragmentNames(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function unknownTypeMessage(typeName: string, suggestedTypes: Array<string>): string;
|
||||
|
||||
/**
|
||||
* Known type names
|
||||
@ -6,4 +9,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL document is only valid if referenced types (specifically
|
||||
* variable definitions and fragment conditions) are defined by the type schema.
|
||||
*/
|
||||
export function KnownTypeNames(context: ValidationContext): any;
|
||||
export function KnownTypeNames(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function anonOperationNotAloneMessage(): string;
|
||||
|
||||
/**
|
||||
* Lone anonymous operation
|
||||
@ -6,4 +9,4 @@ import { ValidationContext } from "../index";
|
||||
* 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): any;
|
||||
export function LoneAnonymousOperation(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function NoFragmentCycles(context: ValidationContext): any;
|
||||
export function cycleErrorMessage(fragName: string, spreadNames: Array<string>): string;
|
||||
|
||||
export function NoFragmentCycles(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function undefinedVarMessage(varName: string, opName: string | void): string;
|
||||
|
||||
/**
|
||||
* No undefined variables
|
||||
@ -6,4 +9,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL operation is only valid if all variables encountered, both directly
|
||||
* and via fragment spreads, are defined by that operation.
|
||||
*/
|
||||
export function NoUndefinedVariables(context: ValidationContext): any;
|
||||
export function NoUndefinedVariables(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function unusedFragMessage(fragName: string): string;
|
||||
|
||||
/**
|
||||
* No unused fragments
|
||||
@ -6,4 +9,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL document is only valid if all fragment definitions are spread
|
||||
* within operations, or spread within other fragments spread within operations.
|
||||
*/
|
||||
export function NoUnusedFragments(context: ValidationContext): any;
|
||||
export function NoUnusedFragments(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function unusedVariableMessage(varName: string, opName: string | void): string;
|
||||
|
||||
/**
|
||||
* No unused variables
|
||||
@ -6,4 +9,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL operation is only valid if all variables defined by an operation
|
||||
* are used, either directly or within a spread fragment.
|
||||
*/
|
||||
export function NoUnusedVariables(context: ValidationContext): any;
|
||||
export function NoUnusedVariables(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function fieldsConflictMessage(responseName: string, reason: ConflictReasonMessage): string;
|
||||
|
||||
/**
|
||||
* Overlapping fields can be merged
|
||||
@ -7,4 +10,10 @@ import { ValidationContext } from "../index";
|
||||
* fragments) either correspond to distinct response names or can be merged
|
||||
* without ambiguity.
|
||||
*/
|
||||
export function OverlappingFieldsCanBeMerged(context: ValidationContext): any;
|
||||
export function OverlappingFieldsCanBeMerged(context: ValidationContext): ASTVisitor;
|
||||
|
||||
// Field name and reason.
|
||||
type ConflictReason = [string, string];
|
||||
|
||||
// Reason is a string, or a nested list of conflicts.
|
||||
type ConflictReasonMessage = string | Array<ConflictReason>;
|
||||
|
||||
@ -1,4 +1,10 @@
|
||||
import { ValidationContext } from "../index";
|
||||
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 typeIncompatibleAnonSpreadMessage(parentType: GraphQLType, fragType: GraphQLType): string;
|
||||
|
||||
/**
|
||||
* Possible fragment spread
|
||||
@ -7,4 +13,4 @@ import { ValidationContext } from "../index";
|
||||
* be true: if there is a non-empty intersection of the possible parent types,
|
||||
* and possible types which pass the type condition.
|
||||
*/
|
||||
export function PossibleFragmentSpreads(context: ValidationContext): any;
|
||||
export function PossibleFragmentSpreads(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,10 @@
|
||||
import { ValidationContext } from "../index";
|
||||
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
|
||||
@ -6,4 +12,4 @@ import { ValidationContext } from "../index";
|
||||
* A field or directive is only valid if all required (non-null) field arguments
|
||||
* have been provided.
|
||||
*/
|
||||
export function ProvidedNonNullArguments(context: ValidationContext): any;
|
||||
export function ProvidedNonNullArguments(context: ValidationContext): ASTVisitor;
|
||||
|
||||
10
types/graphql/validation/rules/ScalarLeafs.d.ts
vendored
10
types/graphql/validation/rules/ScalarLeafs.d.ts
vendored
@ -1,4 +1,10 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
import { GraphQLType } from "../../type/definition";
|
||||
|
||||
export function noSubselectionAllowedMessage(fieldName: string, type: GraphQLType): string;
|
||||
|
||||
export function requiredSubselectionMessage(fieldName: string, type: GraphQLType): string;
|
||||
|
||||
/**
|
||||
* Scalar leafs
|
||||
@ -6,4 +12,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL document is valid only if all leaf fields (fields without
|
||||
* sub selections) are of scalar or enum types.
|
||||
*/
|
||||
export function ScalarLeafs(context: ValidationContext): any;
|
||||
export function ScalarLeafs(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function singleFieldOnlyMessage(name: string | void): string;
|
||||
|
||||
/**
|
||||
* Subscriptions must only include one field.
|
||||
*
|
||||
* A GraphQL subscription is valid only if it contains a single root field.
|
||||
*/
|
||||
export function SingleFieldSubscriptions(context: ValidationContext): any;
|
||||
export function SingleFieldSubscriptions(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function duplicateArgMessage(argName: string): string;
|
||||
|
||||
/**
|
||||
* Unique argument names
|
||||
@ -6,4 +9,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL field or directive is only valid if all supplied arguments are
|
||||
* uniquely named.
|
||||
*/
|
||||
export function UniqueArgumentNames(context: ValidationContext): any;
|
||||
export function UniqueArgumentNames(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function duplicateDirectiveMessage(directiveName: string): string;
|
||||
|
||||
/**
|
||||
* Unique directive names per location
|
||||
@ -6,4 +9,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL document is only valid if all directives at a given location
|
||||
* are uniquely named.
|
||||
*/
|
||||
export function UniqueDirectivesPerLocation(context: ValidationContext): any;
|
||||
export function UniqueDirectivesPerLocation(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function duplicateFragmentNameMessage(fragName: string): string;
|
||||
|
||||
/**
|
||||
* Unique fragment names
|
||||
*
|
||||
* A GraphQL document is only valid if all defined fragments have unique names.
|
||||
*/
|
||||
export function UniqueFragmentNames(context: ValidationContext): any;
|
||||
export function UniqueFragmentNames(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function duplicateInputFieldMessage(fieldName: string): string;
|
||||
|
||||
/**
|
||||
* Unique input field names
|
||||
@ -6,4 +9,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL input object value is only valid if all supplied fields are
|
||||
* uniquely named.
|
||||
*/
|
||||
export function UniqueInputFieldNames(context: ValidationContext): any;
|
||||
export function UniqueInputFieldNames(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function duplicateOperationNameMessage(operationName: string): string;
|
||||
|
||||
/**
|
||||
* Unique operation names
|
||||
*
|
||||
* A GraphQL document is only valid if all defined operations have unique names.
|
||||
*/
|
||||
export function UniqueOperationNames(context: ValidationContext): any;
|
||||
export function UniqueOperationNames(context: ValidationContext): ASTVisitor;
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function duplicateVariableMessage(variableName: string): string;
|
||||
|
||||
/**
|
||||
* Unique variable names
|
||||
*
|
||||
* A GraphQL operation is only valid if all its variables are uniquely named.
|
||||
*/
|
||||
export function UniqueVariableNames(context: ValidationContext): any;
|
||||
export function UniqueVariableNames(context: ValidationContext): ASTVisitor;
|
||||
|
||||
16
types/graphql/validation/rules/ValuesOfCorrectType.d.ts
vendored
Normal file
16
types/graphql/validation/rules/ValuesOfCorrectType.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function badValueMessage(typeName: string, valueName: string, message?: string): string;
|
||||
|
||||
export function requiredFieldMessage(typeName: string, fieldName: string, fieldTypeName: string): string;
|
||||
|
||||
export function unknownFieldMessage(typeName: string, fieldName: string, message?: string): string;
|
||||
|
||||
/**
|
||||
* Value literals of correct type
|
||||
*
|
||||
* A GraphQL document is only valid if all value literals are of the type
|
||||
* expected at their position.
|
||||
*/
|
||||
export function ValuesOfCorrectType(context: ValidationContext): ASTVisitor;
|
||||
@ -1,4 +1,7 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function nonInputTypeOnVarMessage(variableName: string, typeName: string): string;
|
||||
|
||||
/**
|
||||
* Variables are input types
|
||||
@ -6,4 +9,4 @@ import { ValidationContext } from "../index";
|
||||
* A GraphQL operation is only valid if all the variables it defines are of
|
||||
* input types (scalar, enum, or input object).
|
||||
*/
|
||||
export function VariablesAreInputTypes(context: ValidationContext): any;
|
||||
export function VariablesAreInputTypes(context: ValidationContext): ASTVisitor;
|
||||
|
||||
13
types/graphql/validation/rules/VariablesDefaultValueAllowed.d.ts
vendored
Normal file
13
types/graphql/validation/rules/VariablesDefaultValueAllowed.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
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,6 +1,10 @@
|
||||
import { ValidationContext } from "../index";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
import { GraphQLType } from "../../type/definition";
|
||||
|
||||
export function badVarPosMessage(varName: string, varType: GraphQLType, expectedType: GraphQLType): string;
|
||||
|
||||
/**
|
||||
* Variables passed to field arguments conform to type
|
||||
*/
|
||||
export function VariablesInAllowedPosition(context: ValidationContext): any;
|
||||
export function VariablesInAllowedPosition(context: ValidationContext): ASTVisitor;
|
||||
|
||||
5
types/graphql/validation/specifiedRules.d.ts
vendored
5
types/graphql/validation/specifiedRules.d.ts
vendored
@ -1,6 +1,9 @@
|
||||
import { ValidationContext } from "./validate"; // It needs to check.
|
||||
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>;
|
||||
|
||||
81
types/graphql/validation/validate.d.ts
vendored
81
types/graphql/validation/validate.d.ts
vendored
@ -1,23 +1,7 @@
|
||||
import { GraphQLError } from "../error";
|
||||
import {
|
||||
DocumentNode,
|
||||
OperationDefinitionNode,
|
||||
VariableNode,
|
||||
SelectionSetNode,
|
||||
FragmentSpreadNode,
|
||||
FragmentDefinitionNode,
|
||||
} from "../language/ast";
|
||||
import { DocumentNode } from "../language/ast";
|
||||
import { GraphQLSchema } from "../type/schema";
|
||||
import {
|
||||
GraphQLInputType,
|
||||
GraphQLOutputType,
|
||||
GraphQLCompositeType,
|
||||
GraphQLField,
|
||||
GraphQLArgument,
|
||||
} from "../type/definition";
|
||||
import { GraphQLDirective } from "../type/directives";
|
||||
import { TypeInfo } from "../utilities/TypeInfo";
|
||||
import { specifiedRules } from "./specifiedRules";
|
||||
|
||||
/**
|
||||
* Implements the "Validation" section of the spec.
|
||||
@ -31,62 +15,13 @@ import { specifiedRules } from "./specifiedRules";
|
||||
* Each validation rules is a function which returns a visitor
|
||||
* (see the language/visitor API). Visitor methods are expected to return
|
||||
* GraphQLErrors, or Arrays of GraphQLErrors when invalid.
|
||||
*/
|
||||
export function validate(schema: GraphQLSchema, ast: DocumentNode, rules?: any[]): GraphQLError[];
|
||||
|
||||
/**
|
||||
* This uses a specialized visitor which runs multiple visitors in parallel,
|
||||
* while maintaining the visitor skip and break API.
|
||||
*
|
||||
* @internal
|
||||
* Optionally a custom TypeInfo instance may be provided. If not provided, one
|
||||
* will be created from the provided schema.
|
||||
*/
|
||||
export function visitUsingRules(
|
||||
export function validate(
|
||||
schema: GraphQLSchema,
|
||||
typeInfo: TypeInfo,
|
||||
documentAST: DocumentNode,
|
||||
rules: any[]
|
||||
): GraphQLError[];
|
||||
|
||||
export type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode;
|
||||
export interface VariableUsage {
|
||||
node: VariableNode;
|
||||
type: GraphQLInputType;
|
||||
}
|
||||
|
||||
/**
|
||||
* An instance of this class is passed as the "this" context to all validators,
|
||||
* allowing access to commonly useful contextual information from within a
|
||||
* validation rule.
|
||||
*/
|
||||
export class ValidationContext {
|
||||
constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo);
|
||||
reportError(error: GraphQLError): void;
|
||||
|
||||
getErrors(): GraphQLError[];
|
||||
|
||||
getSchema(): GraphQLSchema;
|
||||
|
||||
getDocument(): DocumentNode;
|
||||
|
||||
getFragment(name: string): FragmentDefinitionNode;
|
||||
|
||||
getFragmentSpreads(node: SelectionSetNode): FragmentSpreadNode[];
|
||||
|
||||
getRecursivelyReferencedFragments(operation: OperationDefinitionNode): FragmentDefinitionNode[];
|
||||
|
||||
getVariableUsages(node: NodeWithSelectionSet): VariableUsage[];
|
||||
|
||||
getRecursiveVariableUsages(operation: OperationDefinitionNode): VariableUsage[];
|
||||
|
||||
getType(): GraphQLOutputType;
|
||||
|
||||
getParentType(): GraphQLCompositeType;
|
||||
|
||||
getInputType(): GraphQLInputType;
|
||||
|
||||
getFieldDef(): GraphQLField<any, any>;
|
||||
|
||||
getDirective(): GraphQLDirective;
|
||||
|
||||
getArgument(): GraphQLArgument;
|
||||
}
|
||||
ast: DocumentNode,
|
||||
rules?: ReadonlyArray<any>,
|
||||
typeInfo?: TypeInfo
|
||||
): ReadonlyArray<GraphQLError>;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user