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 ImplementTransitiveInterfaces() Rule
- func ImplementingTypesAreSupersets() Rule
- func KnownArguments() Rule
- func KnownTypeNames() Rule
- func LoneAnonymousOperation() Rule
- func OperationNameUniqueness() Rule
- func PopulatedTypeBodies() Rule
- func RequireDefinedTypesForExtensions() Rule
- func RequiredArguments() Rule
- func SubscriptionSingleRootField() Rule
- func UniqueEnumValueNames() Rule
- func UniqueFieldDefinitionNames() Rule
- func UniqueOperationTypes() Rule
- func UniqueTypeNames() Rule
- func UniqueUnionMemberTypes() 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 NewDefinitionValidator ¶
func NewDefinitionValidator(rules ...Rule) *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 NewOperationValidator ¶
func NewOperationValidator(rules []Rule) *OperationValidator
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 ImplementTransitiveInterfaces ¶
func ImplementTransitiveInterfaces() Rule
func ImplementingTypesAreSupersets ¶
func ImplementingTypesAreSupersets() Rule
func KnownArguments ¶ added in v1.59.1
func KnownArguments() Rule
KnownArguments validates if all arguments are known
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 PopulatedTypeBodies ¶
func PopulatedTypeBodies() Rule
func RequireDefinedTypesForExtensions ¶
func RequireDefinedTypesForExtensions() Rule
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 UniqueUnionMemberTypes ¶
func UniqueUnionMemberTypes() Rule
func ValidArguments ¶
func ValidArguments() Rule
ValidArguments validates if arguments are valid: values and variables has compatible types deep variables comparison is handled by Values
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
Source Files ¶
- definition_validation.go
- operation_rule_all_variable_uses_defined.go
- operation_rule_all_variables_used.go
- operation_rule_argument_uniqueness.go
- operation_rule_directives_defined.go
- operation_rule_directives_in_valid_locations.go
- operation_rule_directives_unique_per_location.go
- operation_rule_document_contains_executable_operation.go
- operation_rule_field_selection_merging.go
- operation_rule_fragments.go
- operation_rule_known_arguments.go
- operation_rule_lone_anonymous_operation.go
- operation_rule_operation_name_uniqueness.go
- operation_rule_required_arguments.go
- operation_rule_subscription_single_root_field.go
- operation_rule_valid_arguments.go
- operation_rule_validate_field_selections.go
- operation_rule_values.go
- operation_rule_variable_uniqueness.go
- operation_rule_variables_are_input_types.go
- operation_validation.go
- rule.go
- rule_implement_transitive_interfaces.go
- rule_implementing_types_are_supersets.go
- rule_known_type_names.go
- rule_populated_type_bodies.go
- rule_require_defined_types_for_extensions.go
- rule_unique_enum_value_names.go
- rule_unique_field_definition_names.go
- rule_unique_operation_types.go
- rule_unique_type_names.go
- rule_unique_union_member_types.go
- validation_state.go
- validation_state_string.go