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 OrList(items ...string) string
- func QuotedOrList(items ...string) string
- func RemoveRule(name string)
- func ReplaceRule(name string, ruleFunc RuleFunc)
- func SuggestionList(input string, options []string) []string
- func Validate(schema *Schema, doc *QueryDocument, rules ...Rule) gqlerror.List
- func ValidateSchemaDocument(sd *SchemaDocument) (*Schema, error)
- func VariableValues(schema *ast.Schema, op *ast.OperationDefinition, ...) (map[string]interface{}, error)
- func Walk(schema *ast.Schema, document *ast.QueryDocument, observers *Events)
- type AddErrFunc
- type ErrorOption
- func At(position *ast.Position) ErrorOption
- func Message(msg string, args ...interface{}) ErrorOption
- func SuggestListQuoted(prefix string, typed string, suggestions []string) ErrorOption
- func SuggestListUnquoted(prefix string, typed string, suggestions []string) ErrorOption
- func Suggestf(suggestion string, args ...interface{}) ErrorOption
- type Events
- func (o *Events) OnDirective(f func(walker *Walker, directive *ast.Directive))
- func (o *Events) OnDirectiveList(f func(walker *Walker, directives []*ast.Directive))
- func (o *Events) OnField(f func(walker *Walker, field *ast.Field))
- func (o *Events) OnFragment(f func(walker *Walker, fragment *ast.FragmentDefinition))
- func (o *Events) OnFragmentSpread(f func(walker *Walker, fragmentSpread *ast.FragmentSpread))
- func (o *Events) OnInlineFragment(f func(walker *Walker, inlineFragment *ast.InlineFragment))
- func (o *Events) OnOperation(f func(walker *Walker, operation *ast.OperationDefinition))
- func (o *Events) OnValue(f func(walker *Walker, value *ast.Value))
- func (o *Events) OnVariable(f func(walker *Walker, variable *ast.VariableDefinition))
- type Rule
- type RuleFunc
- type Walker
Constants ¶
This section is empty.
Variables ¶
var ErrUnexpectedType = fmt.Errorf("Unexpected Type")
var Prelude = &ast.Source{ Name: "prelude.graphql", Input: preludeGraphql, BuiltIn: true, }
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 QuotedOrList ¶
Given [ A, B, C ] return '"A", "B", or "C"'.
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 SuggestionList ¶
Given an invalid input string and a list of valid options, returns a filtered list of valid options sorted based on their similarity with the input.
func ValidateSchemaDocument ¶
func ValidateSchemaDocument(sd *SchemaDocument) (*Schema, error)
func VariableValues ¶
func VariableValues(schema *ast.Schema, op *ast.OperationDefinition, variables map[string]interface{}) (map[string]interface{}, error)
VariableValues coerces and validates variable values
Types ¶
type AddErrFunc ¶
type AddErrFunc func(options ...ErrorOption)
type ErrorOption ¶
func At ¶
func At(position *ast.Position) ErrorOption
func Message ¶
func Message(msg string, args ...interface{}) ErrorOption
func SuggestListQuoted ¶
func SuggestListQuoted(prefix string, typed string, suggestions []string) ErrorOption
func SuggestListUnquoted ¶
func SuggestListUnquoted(prefix string, typed string, suggestions []string) ErrorOption
func Suggestf ¶
func Suggestf(suggestion string, args ...interface{}) ErrorOption
type Events ¶
type Events struct {
// contains filtered or unexported fields
}
func (*Events) OnDirective ¶
func (*Events) OnDirectiveList ¶
func (*Events) OnFragment ¶
func (o *Events) OnFragment(f func(walker *Walker, fragment *ast.FragmentDefinition))
func (*Events) OnFragmentSpread ¶
func (o *Events) OnFragmentSpread(f func(walker *Walker, fragmentSpread *ast.FragmentSpread))
func (*Events) OnInlineFragment ¶
func (o *Events) OnInlineFragment(f func(walker *Walker, inlineFragment *ast.InlineFragment))
func (*Events) OnOperation ¶
func (o *Events) OnOperation(f func(walker *Walker, operation *ast.OperationDefinition))
func (*Events) OnVariable ¶ added in v2.4.0
func (o *Events) OnVariable(f func(walker *Walker, variable *ast.VariableDefinition))
type RuleFunc ¶ added in v2.5.17
type RuleFunc func(observers *Events, addError AddErrFunc)