Documentation
¶
Index ¶
- func DefaultRules() []validator.Option
- func WalkAllValues(doc *ast.QueryDocument, fn func(*ast.Value))
- func WalkAllValuesInOperation(op *ast.OperationDefinition, fn func(*ast.Value))
- func WalkDirectivesInSelections(selections ast.SelectionSet, fn func([]*ast.Directive))
- func WalkValueRecursive(value *ast.Value, fn func(*ast.Value))
- func WalkValuesInSelections(selections ast.SelectionSet, fn func(*ast.Value))
- type BaseInlineRule
- func (BaseInlineRule) EnterArgument(*validator.WalkContext, *ast.ArgumentDefinition, *ast.Argument) gqlerror.List
- func (BaseInlineRule) EnterDirective(*validator.WalkContext, *ast.Definition, *ast.Directive) gqlerror.List
- func (BaseInlineRule) EnterField(*validator.WalkContext, *ast.Definition, *ast.Field) gqlerror.List
- func (BaseInlineRule) EnterFragment(*validator.WalkContext, *ast.Definition, ast.Selection) gqlerror.List
- type FieldsOnCorrectType
- type FragmentsOnCompositeTypes
- type KnownArgumentNames
- type KnownDirectives
- type KnownTypeNames
- type LoneAnonymousOperation
- type MaxIntrospectionDepth
- type NoFragmentCycles
- type NoUndefinedVariables
- type NoUnusedFragments
- type OverlappingFieldsCanBeMerged
- type PossibleFragmentSpreads
- type ProvidedRequiredArguments
- type ScalarLeafs
- type SingleFieldSubscriptions
- type UniqueArgumentNames
- type UniqueDirectivesPerLocation
- type UniqueFragmentNames
- type UniqueInputFieldNames
- type UniqueOperationNames
- type UniqueVariableNames
- type ValuesOfCorrectType
- type VariablesAreInputTypes
- type VariablesInAllowedPosition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRules ¶
DefaultRules returns the full set of GraphQL spec validation rules. Mirrors gqlparser's default rules minus NoUnusedVariablesRule.
func WalkAllValues ¶
func WalkAllValues(doc *ast.QueryDocument, fn func(*ast.Value))
WalkAllValues walks all argument/default values in a document.
func WalkAllValuesInOperation ¶
func WalkAllValuesInOperation(op *ast.OperationDefinition, fn func(*ast.Value))
WalkAllValuesInOperation walks all values (variable defaults + argument values) in an operation.
func WalkDirectivesInSelections ¶
func WalkDirectivesInSelections(selections ast.SelectionSet, fn func([]*ast.Directive))
WalkDirectivesInSelections walks directives in all selections recursively.
func WalkValueRecursive ¶
WalkValueRecursive visits a value and all its children.
func WalkValuesInSelections ¶
func WalkValuesInSelections(selections ast.SelectionSet, fn func(*ast.Value))
WalkValuesInSelections walks all argument values in a selection set.
Types ¶
type BaseInlineRule ¶
type BaseInlineRule struct{}
BaseInlineRule provides no-op implementations for all InlineRule methods. Embed it in inline rules and override only the relevant method.
func (BaseInlineRule) EnterArgument ¶
func (BaseInlineRule) EnterArgument(*validator.WalkContext, *ast.ArgumentDefinition, *ast.Argument) gqlerror.List
func (BaseInlineRule) EnterDirective ¶
func (BaseInlineRule) EnterDirective(*validator.WalkContext, *ast.Definition, *ast.Directive) gqlerror.List
func (BaseInlineRule) EnterField ¶
func (BaseInlineRule) EnterField(*validator.WalkContext, *ast.Definition, *ast.Field) gqlerror.List
func (BaseInlineRule) EnterFragment ¶
func (BaseInlineRule) EnterFragment(*validator.WalkContext, *ast.Definition, ast.Selection) gqlerror.List
type FieldsOnCorrectType ¶
type FieldsOnCorrectType struct{ BaseInlineRule }
FieldsOnCorrectType checks that a queried field exists on the parent type.
func (*FieldsOnCorrectType) EnterField ¶
func (r *FieldsOnCorrectType) EnterField(_ *validator.WalkContext, parentDef *ast.Definition, field *ast.Field) gqlerror.List
type FragmentsOnCompositeTypes ¶
type FragmentsOnCompositeTypes struct{ BaseInlineRule }
FragmentsOnCompositeTypes checks that fragments are only defined on composite types.
func (*FragmentsOnCompositeTypes) EnterFragment ¶
func (r *FragmentsOnCompositeTypes) EnterFragment(ctx *validator.WalkContext, _ *ast.Definition, frag ast.Selection) gqlerror.List
type KnownArgumentNames ¶
type KnownArgumentNames struct{ BaseInlineRule }
KnownArgumentNames checks that arguments exist on the field or directive definition.
func (*KnownArgumentNames) EnterArgument ¶
func (r *KnownArgumentNames) EnterArgument(_ *validator.WalkContext, argDef *ast.ArgumentDefinition, arg *ast.Argument) gqlerror.List
type KnownDirectives ¶
type KnownDirectives struct{ BaseInlineRule }
KnownDirectives checks that directives are defined and used at correct locations.
func (*KnownDirectives) EnterDirective ¶
func (r *KnownDirectives) EnterDirective(_ *validator.WalkContext, _ *ast.Definition, dir *ast.Directive) gqlerror.List
type KnownTypeNames ¶
type KnownTypeNames struct{ BaseInlineRule }
KnownTypeNames checks that type conditions in fragments reference known schema types.
func (*KnownTypeNames) EnterFragment ¶
func (r *KnownTypeNames) EnterFragment(ctx *validator.WalkContext, _ *ast.Definition, frag ast.Selection) gqlerror.List
type LoneAnonymousOperation ¶
type LoneAnonymousOperation struct{}
LoneAnonymousOperation checks that anonymous operations are the only defined operation.
func (*LoneAnonymousOperation) Validate ¶
func (r *LoneAnonymousOperation) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type MaxIntrospectionDepth ¶
type MaxIntrospectionDepth struct{}
MaxIntrospectionDepth prevents excessively deep queries.
func (*MaxIntrospectionDepth) Validate ¶
func (r *MaxIntrospectionDepth) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type NoFragmentCycles ¶
type NoFragmentCycles struct{}
NoFragmentCycles checks that fragments do not form cycles.
func (*NoFragmentCycles) Validate ¶
func (r *NoFragmentCycles) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type NoUndefinedVariables ¶
type NoUndefinedVariables struct{}
NoUndefinedVariables checks that all used variables are defined in the operation.
func (*NoUndefinedVariables) Validate ¶
func (r *NoUndefinedVariables) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type NoUnusedFragments ¶
type NoUnusedFragments struct{}
NoUnusedFragments checks that all defined fragments are used.
func (*NoUnusedFragments) Validate ¶
func (r *NoUnusedFragments) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type OverlappingFieldsCanBeMerged ¶
type OverlappingFieldsCanBeMerged struct{}
OverlappingFieldsCanBeMerged checks that fields with the same response name can be merged.
func (*OverlappingFieldsCanBeMerged) Validate ¶
func (r *OverlappingFieldsCanBeMerged) Validate(ctx *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type PossibleFragmentSpreads ¶
type PossibleFragmentSpreads struct{}
PossibleFragmentSpreads checks that fragments spread on types that are valid for the parent.
func (*PossibleFragmentSpreads) Validate ¶
func (r *PossibleFragmentSpreads) Validate(ctx *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type ProvidedRequiredArguments ¶
type ProvidedRequiredArguments struct{}
ProvidedRequiredArguments checks that all required arguments are provided.
func (*ProvidedRequiredArguments) Validate ¶
func (r *ProvidedRequiredArguments) Validate(ctx *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type ScalarLeafs ¶
type ScalarLeafs struct{ BaseInlineRule }
ScalarLeafs checks that leaf types have no selections and composite types have selections.
func (*ScalarLeafs) EnterField ¶
func (r *ScalarLeafs) EnterField(ctx *validator.WalkContext, _ *ast.Definition, field *ast.Field) gqlerror.List
type SingleFieldSubscriptions ¶
type SingleFieldSubscriptions struct{}
SingleFieldSubscriptions checks that subscriptions select only one top-level field.
func (*SingleFieldSubscriptions) Validate ¶
func (r *SingleFieldSubscriptions) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type UniqueArgumentNames ¶
type UniqueArgumentNames struct{}
UniqueArgumentNames checks that arguments are unique within each field and directive.
func (*UniqueArgumentNames) Validate ¶
func (r *UniqueArgumentNames) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type UniqueDirectivesPerLocation ¶
type UniqueDirectivesPerLocation struct{}
UniqueDirectivesPerLocation checks that non-repeatable directives are unique per location.
func (*UniqueDirectivesPerLocation) Validate ¶
func (r *UniqueDirectivesPerLocation) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type UniqueFragmentNames ¶
type UniqueFragmentNames struct{}
UniqueFragmentNames checks that fragment names are unique.
func (*UniqueFragmentNames) Validate ¶
func (r *UniqueFragmentNames) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type UniqueInputFieldNames ¶
type UniqueInputFieldNames struct{}
UniqueInputFieldNames checks that input object fields are unique.
func (*UniqueInputFieldNames) Validate ¶
func (r *UniqueInputFieldNames) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type UniqueOperationNames ¶
type UniqueOperationNames struct{}
UniqueOperationNames checks that operation names are unique.
func (*UniqueOperationNames) Validate ¶
func (r *UniqueOperationNames) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type UniqueVariableNames ¶
type UniqueVariableNames struct{}
UniqueVariableNames checks that variable names are unique within an operation.
func (*UniqueVariableNames) Validate ¶
func (r *UniqueVariableNames) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type ValuesOfCorrectType ¶
type ValuesOfCorrectType struct{}
ValuesOfCorrectType checks that literal values are compatible with their expected type.
func (*ValuesOfCorrectType) Validate ¶
func (r *ValuesOfCorrectType) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type VariablesAreInputTypes ¶
type VariablesAreInputTypes struct{}
VariablesAreInputTypes checks that variables are declared with input types.
func (*VariablesAreInputTypes) Validate ¶
func (r *VariablesAreInputTypes) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
type VariablesInAllowedPosition ¶
type VariablesInAllowedPosition struct{}
VariablesInAllowedPosition checks that variable types are compatible with their usage.
func (*VariablesInAllowedPosition) Validate ¶
func (r *VariablesInAllowedPosition) Validate(_ *validator.WalkContext, doc *ast.QueryDocument) gqlerror.List
Source Files
¶
- defaults.go
- fields_on_correct_type.go
- fragments_on_composite_types.go
- helpers.go
- known_argument_names.go
- known_directives.go
- known_type_names.go
- lone_anonymous_operation.go
- max_introspection_depth.go
- no_fragment_cycles.go
- no_undefined_variables.go
- no_unused_fragments.go
- overlapping_fields_can_be_merged.go
- possible_fragment_spreads.go
- provided_required_arguments.go
- scalar_leafs.go
- single_field_subscriptions.go
- unique_argument_names.go
- unique_directives_per_location.go
- unique_fragment_names.go
- unique_input_field_names.go
- unique_operation_names.go
- unique_variable_names.go
- values_of_correct_type.go
- variables_are_input_types.go
- variables_in_allowed_position.go