Documentation ¶
Overview ¶
Package astvalidation implements the validation rules specified in the GraphQL specification.
Index ¶
- type DefinitionValidator
- type OperationValidator
- type Rule
- func AllVariableUsesDefined() Rule
- func AllVariablesUsed() Rule
- func ArgumentUniqueness() Rule
- func DirectivesAreDefined() Rule
- func DirectivesAreInValidLocations() Rule
- func DirectivesAreUniquePerLocation() Rule
- func DocumentContainsExecutableOperation() Rule
- func FieldSelectionMerging() Rule
- func FieldSelections() Rule
- func Fragments() Rule
- func KnownTypeNames() Rule
- func LoneAnonymousOperation() Rule
- func OperationNameUniqueness() Rule
- func RequiredArguments() Rule
- func SubscriptionSingleRootField() Rule
- func UniqueEnumValueNames() Rule
- func UniqueFieldDefinitionNames() Rule
- func UniqueOperationTypes() Rule
- func UniqueTypeNames() Rule
- func ValidArguments() Rule
- func Values() Rule
- func VariableUniqueness() Rule
- func VariablesAreInputTypes() Rule
- type ValidationState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefinitionValidator ¶
type DefinitionValidator struct {
// contains filtered or unexported fields
}
func DefaultDefinitionValidator ¶
func DefaultDefinitionValidator() *DefinitionValidator
func (*DefinitionValidator) RegisterRule ¶
func (d *DefinitionValidator) RegisterRule(rule Rule)
func (*DefinitionValidator) Validate ¶
func (d *DefinitionValidator) Validate(definition *ast.Document, report *operationreport.Report) ValidationState
type OperationValidator ¶
type OperationValidator struct {
// contains filtered or unexported fields
}
OperationValidator orchestrates the validation process of Operations
func DefaultOperationValidator ¶
func DefaultOperationValidator() *OperationValidator
DefaultOperationValidator returns a fully initialized OperationValidator with all default rules registered
func (*OperationValidator) RegisterRule ¶
func (o *OperationValidator) RegisterRule(rule Rule)
RegisterRule registers a rule to the OperationValidator
func (*OperationValidator) Validate ¶
func (o *OperationValidator) Validate(operation, definition *ast.Document, report *operationreport.Report) ValidationState
Validate validates the operation against the definition using the registered ruleset.
type Rule ¶
type Rule func(walker *astvisitor.Walker)
Rule is hook to register callback functions on the Walker
func AllVariableUsesDefined ¶
func AllVariableUsesDefined() Rule
AllVariableUsesDefined validates if used variables are defined within the operation
func AllVariablesUsed ¶
func AllVariablesUsed() Rule
AllVariablesUsed validates if all defined variables are used
func ArgumentUniqueness ¶
func ArgumentUniqueness() Rule
ArgumentUniqueness validates if arguments are unique
func DirectivesAreDefined ¶
func DirectivesAreDefined() Rule
DirectivesAreDefined validates if used directives are defined
func DirectivesAreInValidLocations ¶
func DirectivesAreInValidLocations() Rule
DirectivesAreInValidLocations validates if directives are used in the right place
func DirectivesAreUniquePerLocation ¶
func DirectivesAreUniquePerLocation() Rule
DirectivesAreUniquePerLocation validates if directives are unique per location
func DocumentContainsExecutableOperation ¶
func DocumentContainsExecutableOperation() Rule
DocumentContainsExecutableOperation validates if the document actually contains an executable Operation
func FieldSelectionMerging ¶
func FieldSelectionMerging() Rule
FieldSelectionMerging validates if field selections can be merged
func FieldSelections ¶
func FieldSelections() Rule
FieldSelections validates if all FieldSelections are possible and valid
func Fragments ¶
func Fragments() Rule
Fragments validates if the use of fragments in a given document is correct
func KnownTypeNames ¶
func KnownTypeNames() Rule
func LoneAnonymousOperation ¶
func LoneAnonymousOperation() Rule
LoneAnonymousOperation validates if anonymous operations are alone in a given document.
func OperationNameUniqueness ¶
func OperationNameUniqueness() Rule
OperationNameUniqueness validates if all operation names are unique
func RequiredArguments ¶
func RequiredArguments() Rule
RequiredArguments validates if all required arguments are present
func SubscriptionSingleRootField ¶
func SubscriptionSingleRootField() Rule
SubscriptionSingleRootField validates if subscriptions have a single root field
func UniqueEnumValueNames ¶
func UniqueEnumValueNames() Rule
func UniqueFieldDefinitionNames ¶
func UniqueFieldDefinitionNames() Rule
func UniqueOperationTypes ¶
func UniqueOperationTypes() Rule
func UniqueTypeNames ¶
func UniqueTypeNames() Rule
func VariableUniqueness ¶
func VariableUniqueness() Rule
VariableUniqueness validates if variables are unique in a given document
func VariablesAreInputTypes ¶
func VariablesAreInputTypes() Rule
VariablesAreInputTypes validates if variables are correct input types
type ValidationState ¶
type ValidationState int
ValidationState is the outcome of a validation
const ( UnknownState ValidationState = iota Valid Invalid )
func (ValidationState) String ¶
func (i ValidationState) String() string