graphql-0.11.1.0: Haskell GraphQL implementation
Safe HaskellNone
LanguageHaskell2010

Language.GraphQL.Validate

Description

GraphQL validator.

Synopsis

Documentation

data Error Source #

Validation error.

Constructors

Error 

Fields

Instances

Instances details
Eq Error Source # 
Instance details

Defined in Language.GraphQL.Validate.Validation

Methods

(==) :: Error -> Error -> Bool #

(/=) :: Error -> Error -> Bool #

Show Error Source # 
Instance details

Defined in Language.GraphQL.Validate.Validation

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #

document :: forall m. Schema m -> [Rule m] -> Document -> Seq Error Source #

Validates a document and returns a list of found errors. If the returned list is empty, the document is valid.

directivesInValidLocationsRule :: Rule m Source #

GraphQL servers define what directives they support and where they support them. For each usage of a directive, the directive must be used in a location that the server has declared support for.

executableDefinitionsRule :: forall m. Rule m Source #

Definition must be OperationDefinition or FragmentDefinition.

fieldsOnCorrectTypeRule :: forall m. Rule m Source #

The target field of a field selection must be defined on the scoped type of the selection set. There are no limitations on alias names.

fragmentsOnCompositeTypesRule :: forall m. Rule m Source #

Fragments can only be declared on unions, interfaces, and objects. They are invalid on scalars. They can only be applied on non‐leaf fields. This rule applies to both inline and named fragments.

fragmentSpreadTargetDefinedRule :: forall m. Rule m Source #

Named fragment spreads must refer to fragments defined within the document. It is a validation error if the target of a spread is not defined.

fragmentSpreadTypeExistenceRule :: forall m. Rule m Source #

Fragments must be specified on types that exist in the schema. This applies for both named and inline fragments. If they are not defined in the schema, the query does not validate.

loneAnonymousOperationRule :: forall m. Rule m Source #

GraphQL allows a short‐hand form for defining query operations when only that one operation exists in the document.

knownArgumentNamesRule :: forall m. Rule m Source #

Every argument provided to a field or directive must be defined in the set of possible arguments of that field or directive.

knownDirectiveNamesRule :: Rule m Source #

GraphQL servers define what directives they support. For each usage of a directive, the directive must be available on that server.

knownInputFieldNamesRule :: Rule m Source #

Every input field provided in an input object value must be defined in the set of possible fields of that input object’s expected type.

noFragmentCyclesRule :: forall m. Rule m Source #

The graph of fragment spreads must not form any cycles including spreading itself. Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data.

noUndefinedVariablesRule :: forall m. Rule m Source #

Variables are scoped on a per‐operation basis. That means that any variable used within the context of an operation must be defined at the top level of that operation.

noUnusedFragmentsRule :: forall m. Rule m Source #

Defined fragments must be used within a document.

noUnusedVariablesRule :: forall m. Rule m Source #

All variables defined by an operation must be used in that operation or a fragment transitively included by that operation. Unused variables cause a validation error.

overlappingFieldsCanBeMergedRule :: Rule m Source #

If multiple field selections with the same response names are encountered during execution, the field and arguments to execute and the resulting value should be unambiguous. Therefore any two field selections which might both be encountered for the same object are only valid if they are equivalent.

For simple hand‐written GraphQL, this rule is obviously a clear developer error, however nested fragments can make this difficult to detect manually.

possibleFragmentSpreadsRule :: forall m. Rule m Source #

Fragments are declared on a type and will only apply when the runtime object type matches the type condition. They also are spread within the context of a parent type. A fragment spread is only valid if its type condition could ever apply within the parent type.

providedRequiredInputFieldsRule :: Rule m Source #

Input object fields may be required. Much like a field may have required arguments, an input object may have required fields. An input field is required if it has a non‐null type and does not have a default value. Otherwise, the input object field is optional.

providedRequiredArgumentsRule :: Rule m Source #

Arguments can be required. An argument is required if the argument type is non‐null and does not have a default value. Otherwise, the argument is optional.

scalarLeafsRule :: forall m. Rule m Source #

Field selections on scalars or enums are never allowed, because they are the leaf nodes of any GraphQL query.

singleFieldSubscriptionsRule :: forall m. Rule m Source #

Subscription operations must have exactly one root field.

specifiedRules :: forall m. [Rule m] Source #

Default rules given in the specification.

uniqueArgumentNamesRule :: forall m. Rule m Source #

Fields and directives treat arguments as a mapping of argument name to value. More than one argument with the same name in an argument set is ambiguous and invalid.

uniqueDirectiveNamesRule :: forall m. Rule m Source #

Directives are used to describe some metadata or behavioral change on the definition they apply to. When more than one directive of the same name is used, the expected metadata or behavior becomes ambiguous, therefore only one of each directive is allowed per location.

uniqueFragmentNamesRule :: forall m. Rule m Source #

Fragment definitions are referenced in fragment spreads by name. To avoid ambiguity, each fragment’s name must be unique within a document.

Inline fragments are not considered fragment definitions, and are unaffected by this validation rule.

uniqueInputFieldNamesRule :: forall m. Rule m Source #

Input objects must not contain more than one field of the same name, otherwise an ambiguity would exist which includes an ignored portion of syntax.

uniqueOperationNamesRule :: forall m. Rule m Source #

Each named operation definition must be unique within a document when referred to by its name.

uniqueVariableNamesRule :: forall m. Rule m Source #

If any operation defines more than one variable with the same name, it is ambiguous and invalid. It is invalid even if the type of the duplicate variable is the same.

valuesOfCorrectTypeRule :: forall m. Rule m Source #

Literal values must be compatible with the type expected in the position they are found as per the coercion rules.

The type expected in a position include the type defined by the argument a value is provided for, the type defined by an input object field a value is provided for, and the type of a variable definition a default value is provided for.

variablesInAllowedPositionRule :: forall m. Rule m Source #

Variable usages must be compatible with the arguments they are passed to.

Validation failures occur when variables are used in the context of types that are complete mismatches, or if a nullable type in a variable is passed to a non‐null argument type.

variablesAreInputTypesRule :: forall m. Rule m Source #

Variables can only be input types. Objects, unions and interfaces cannot be used as inputs.