astvalidation

package
v1.67.4 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 9 Imported by: 2

Documentation

Overview

Package astvalidation implements the validation rules specified in the GraphQL specification.

Index

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 Values

func Values() Rule

Values validates if values are used properly

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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