selections

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package selections is for internal use to share selection context between the execution engine and the public graphql package without creating an import cycle.

The execution layer stores the flattened child selection set for the field currently being resolved. The public API converts this into user-friendly helpers (SelectedFieldNames, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func With

func With(ctx context.Context, sels []selected.Selection) context.Context

With stores a lazy wrapper for selections in the context.

Types

type Lazy

type Lazy struct {
	// contains filtered or unexported fields
}

Lazy holds raw selections and computes the flattened, deduped name list once on demand.

func FromContext

func FromContext(ctx context.Context) *Lazy

FromContext retrieves the lazy wrapper (may be nil).

func (*Lazy) Args

func (l *Lazy) Args(path string) (map[string]interface{}, bool)

Args returns the argument map for the first occurrence of the provided dot-delimited field path under the current resolver. The boolean reports if a matching field was found. The returned map MUST NOT be mutated by callers (it is the internal map). Paths follow the same format produced by SelectedFieldNames (e.g. "books", "books.reviews").

func (*Lazy) DecodeArgsInto

func (l *Lazy) DecodeArgsInto(path string, dst interface{}) (bool, error)

DecodeArgsInto decodes the argument map for the dot path into dst (pointer to struct). Returns (true,nil) if decoded, (false,nil) if path missing. Caches per path+type.

func (*Lazy) Has

func (l *Lazy) Has(name string) bool

Has reports if a field name is in the selection list.

func (*Lazy) Names

func (l *Lazy) Names() []string

Names returns the deduplicated child field names computing them once.

Jump to

Keyboard shortcuts

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