Documentation
¶
Index ¶
- Variables
- func AddRule(name string, ruleFunc RuleFunc)
- func IsValidFloatString(val reflect.Value, kind reflect.Kind) bool
- func IsValidIntString(val reflect.Value, kind reflect.Kind) bool
- func LoadSchema(inputs ...*Source) (*Schema, error)
- func PreludeDocument() *ast.SchemaDocument
- func QueryIntrospectionFields() ast.FieldList
- func RemoveRule(name string)
- func ReplaceRule(name string, ruleFunc RuleFunc)
- func Validate(schema *Schema, doc *QueryDocument, rules ...Rule) gqlerror.Listdeprecated
- func ValidateSchemaDocument(sd *SchemaDocument) (*Schema, error)
- func ValidateWithRules(schema *Schema, doc *QueryDocument, rules *validatorrules.Rules) gqlerror.List
- func ValidateWithRulesWithSources(schema *Schema, doc *QueryDocument, rules *validatorrules.Rules) gqlerror.SourceList
- func ValidateWithSources(schema *Schema, doc *QueryDocument, rules ...Rule) gqlerror.SourceList
- func VariableValues(schema *ast.Schema, op *ast.OperationDefinition, variables map[string]any) (map[string]any, error)
- func Walk(schema *Schema, document *QueryDocument, observers *Events)
- type AddErrFunc
- type EmptyDefinitionError
- type ErrorOption
- type Events
- type Rule
- type RuleFunc
- type Walker
Constants ¶
This section is empty.
Variables ¶
var ( Message = core.Message QuotedOrList = core.QuotedOrList OrList = core.OrList )
var ErrUnexpectedType = errors.New("Unexpected Type")
var Prelude = &ast.Source{ Name: "prelude.graphql", Input: preludeGraphql, BuiltIn: true, }
Prelude is the GraphQL source of the types and directives the spec declares implicitly. gqlparser.LoadSchema adds it ahead of the caller's sources.
Functions ¶
func AddRule ¶
AddRule adds a rule to the rule set. ruleFunc is called once each time `Validate` is executed.
func IsValidFloatString ¶ added in v2.4.2
func IsValidIntString ¶ added in v2.4.2
func LoadSchema ¶
func LoadSchema(inputs ...*Source) (*Schema, error)
func PreludeDocument ¶ added in v2.5.64
func PreludeDocument() *ast.SchemaDocument
PreludeDocument returns the parsed Prelude: the built-in scalars, directives and introspection types that LoadSchema adds to every schema. Use it to find out what this version of gqlparser declares, instead of keeping a copy of those names.
Each call parses Prelude again, so the caller owns the result and may modify it. It panics if the embedded prelude does not parse, which is a gqlparser bug.
func QueryIntrospectionFields ¶ added in v2.5.64
QueryIntrospectionFields returns the __schema and __type fields that the spec adds to the query root type. ValidateSchemaDocument appends them to the query type it finds; a caller that supplies its own query type needs them too.
Each call returns new definitions, so the caller owns the result.
func RemoveRule ¶ added in v2.5.18
func RemoveRule(name string)
RemoveRule removes an existing rule from the rule set if one of the same name exists. The rule set is global, so it is not safe for concurrent changes.
func ReplaceRule ¶ added in v2.5.21
ReplaceRule replaces an existing rule from the rule set if one of the same name exists. If no match is found, it will add a new rule to the rule set. The rule set is global, so it is not safe for concurrent changes.
func ValidateSchemaDocument ¶
func ValidateSchemaDocument(sd *SchemaDocument) (*Schema, error)
func ValidateWithRules ¶ added in v2.5.29
func ValidateWithRules( schema *Schema, doc *QueryDocument, rules *validatorrules.Rules, ) gqlerror.List
func ValidateWithRulesWithSources ¶ added in v2.5.37
func ValidateWithRulesWithSources( schema *Schema, doc *QueryDocument, rules *validatorrules.Rules, ) gqlerror.SourceList
ValidateWithRulesWithSources is the source-aware counterpart to ValidateWithRules.
func ValidateWithSources ¶ added in v2.5.37
func ValidateWithSources(schema *Schema, doc *QueryDocument, rules ...Rule) gqlerror.SourceList
ValidateWithSources is the source-aware counterpart to Validate. It keeps source documents for every location recorded by the built-in At option while leaving Error and the regular validation API unchanged.
Types ¶
type AddErrFunc ¶
type AddErrFunc = core.AddErrFunc
type EmptyDefinitionError ¶ added in v2.5.59
type EmptyDefinitionError struct {
Definition *ast.Definition
}
func (*EmptyDefinitionError) Error ¶ added in v2.5.59
func (n *EmptyDefinitionError) Error() string
Error implements [error].
type ErrorOption ¶
type ErrorOption = core.ErrorOption
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
preludegen
command
Command preludegen writes validator/prelude_directives.go, which reports the directives validator/imported/prelude.graphql declares.
|
Command preludegen writes validator/prelude_directives.go, which reports the directives validator/imported/prelude.graphql declares. |