Help us shape the future of Go! Take the 2026 Go Developer Survey

rules

package
v0.3.45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultRules

func DefaultRules() []validator.Option

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

func WalkValueRecursive(value *ast.Value, fn func(*ast.Value))

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) EnterDirective

func (BaseInlineRule) EnterField

func (BaseInlineRule) EnterFragment

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

type KnownArgumentNames

type KnownArgumentNames struct{ BaseInlineRule }

KnownArgumentNames checks that arguments exist on the field or directive definition.

func (*KnownArgumentNames) EnterArgument

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

type MaxIntrospectionDepth

type MaxIntrospectionDepth struct{}

MaxIntrospectionDepth prevents excessively deep queries.

func (*MaxIntrospectionDepth) Validate

type NoFragmentCycles

type NoFragmentCycles struct{}

NoFragmentCycles checks that fragments do not form cycles.

func (*NoFragmentCycles) Validate

type NoUndefinedVariables

type NoUndefinedVariables struct{}

NoUndefinedVariables checks that all used variables are defined in the operation.

func (*NoUndefinedVariables) Validate

type NoUnusedFragments

type NoUnusedFragments struct{}

NoUnusedFragments checks that all defined fragments are used.

func (*NoUnusedFragments) Validate

type OverlappingFieldsCanBeMerged

type OverlappingFieldsCanBeMerged struct{}

OverlappingFieldsCanBeMerged checks that fields with the same response name can be merged.

func (*OverlappingFieldsCanBeMerged) Validate

type PossibleFragmentSpreads

type PossibleFragmentSpreads struct{}

PossibleFragmentSpreads checks that fragments spread on types that are valid for the parent.

func (*PossibleFragmentSpreads) Validate

type ProvidedRequiredArguments

type ProvidedRequiredArguments struct{}

ProvidedRequiredArguments checks that all required arguments are provided.

func (*ProvidedRequiredArguments) Validate

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

type UniqueArgumentNames

type UniqueArgumentNames struct{}

UniqueArgumentNames checks that arguments are unique within each field and directive.

func (*UniqueArgumentNames) Validate

type UniqueDirectivesPerLocation

type UniqueDirectivesPerLocation struct{}

UniqueDirectivesPerLocation checks that non-repeatable directives are unique per location.

func (*UniqueDirectivesPerLocation) Validate

type UniqueFragmentNames

type UniqueFragmentNames struct{}

UniqueFragmentNames checks that fragment names are unique.

func (*UniqueFragmentNames) Validate

type UniqueInputFieldNames

type UniqueInputFieldNames struct{}

UniqueInputFieldNames checks that input object fields are unique.

func (*UniqueInputFieldNames) Validate

type UniqueOperationNames

type UniqueOperationNames struct{}

UniqueOperationNames checks that operation names are unique.

func (*UniqueOperationNames) Validate

type UniqueVariableNames

type UniqueVariableNames struct{}

UniqueVariableNames checks that variable names are unique within an operation.

func (*UniqueVariableNames) Validate

type ValuesOfCorrectType

type ValuesOfCorrectType struct{}

ValuesOfCorrectType checks that literal values are compatible with their expected type.

func (*ValuesOfCorrectType) Validate

type VariablesAreInputTypes

type VariablesAreInputTypes struct{}

VariablesAreInputTypes checks that variables are declared with input types.

func (*VariablesAreInputTypes) Validate

type VariablesInAllowedPosition

type VariablesInAllowedPosition struct{}

VariablesInAllowedPosition checks that variable types are compatible with their usage.

func (*VariablesInAllowedPosition) Validate

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL