gqlgen

package
v0.0.0-...-90138cf Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrArgumentNotFound = fmt.Errorf("%w: argument", errorz.ErrNotFound)

ErrArgumentNotFound is returned when no argument with the given name can be located in gqlgen field at the given path. This error could indicated that an optional argument was simply not provided in the GraphQL query itself.

View Source
var ErrFieldNotFound = fmt.Errorf("%w: field", errorz.ErrNotFound)

ErrFieldNotFound is returned when no field can be located in the gqlgen context at the given path.

Functions

func FindField

func FindField(ctx context.Context, path string, fctx *graphql.FieldContext) *graphql.CollectedField

FindField does a depth-first search of the gqlgen context for the field identified by path.

func GetArgList

func GetArgList(ctx context.Context, path string) (ast.ArgumentList, error)

GetArgList searches the gqlgen context for a query field identified by path and returns the list of arguments passed to the query.

func GetArgValue

func GetArgValue[T any](ctx context.Context, key ArgKey) (*T, error)

GetArgValue searches the gqlgen context for a query argument identified by path and name in the ArgKey, and returns the value casted to the given type T. GetArgValue returns an error if:

  • The context is not a gqlgen-provided context
  • The field specified by the path is not found in the query
  • The argument is not provided in the identified query field
  • The value of the argument cannot be cast to the desired type.

func MustGetArgValue

func MustGetArgValue[T any](ctx context.Context, key ArgKey) *T

MustGetArgValue is a convenience function that wraps GetArgValue, but panics if an error occurs.

Types

type ArgKey

type ArgKey struct {
	Path string
	Name string
}

ArgKey is an object that must be provided when attempting to get an argument from a gqlgen context. The path represents the JSON path into the query, while the name identifies the argument.

func (ArgKey) String

func (a ArgKey) String() string

Jump to

Keyboard shortcuts

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