Documentation
¶
Index ¶
- Variables
- func FindField(ctx context.Context, path string, fctx *graphql.FieldContext) *graphql.CollectedField
- func GetArgList(ctx context.Context, path string) (ast.ArgumentList, error)
- func GetArgValue[T any](ctx context.Context, key ArgKey) (*T, error)
- func MustGetArgValue[T any](ctx context.Context, key ArgKey) *T
- type ArgKey
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
GetArgList searches the gqlgen context for a query field identified by path and returns the list of arguments passed to the query.
func GetArgValue ¶
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.