dagql

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const InstrumentationLibrary = "dagger.io/dagql"

Variables

View Source
var (
	DirectiveLocationQuery                = DirectiveLocations.Register("QUERY")
	DirectiveLocationMutation             = DirectiveLocations.Register("MUTATION")
	DirectiveLocationSubscription         = DirectiveLocations.Register("SUBSCRIPTION")
	DirectiveLocationField                = DirectiveLocations.Register("FIELD")
	DirectiveLocationFragmentDefinition   = DirectiveLocations.Register("FRAGMENT_DEFINITION")
	DirectiveLocationFragmentSpread       = DirectiveLocations.Register("FRAGMENT_SPREAD")
	DirectiveLocationInlineFragment       = DirectiveLocations.Register("INLINE_FRAGMENT")
	DirectiveLocationVariableDefinition   = DirectiveLocations.Register("VARIABLE_DEFINITION")
	DirectiveLocationSchema               = DirectiveLocations.Register("SCHEMA")
	DirectiveLocationScalar               = DirectiveLocations.Register("SCALAR")
	DirectiveLocationObject               = DirectiveLocations.Register("OBJECT")
	DirectiveLocationFieldDefinition      = DirectiveLocations.Register("FIELD_DEFINITION")
	DirectiveLocationArgumentDefinition   = DirectiveLocations.Register("ARGUMENT_DEFINITION")
	DirectiveLocationInterface            = DirectiveLocations.Register("INTERFACE")
	DirectiveLocationUnion                = DirectiveLocations.Register("UNION")
	DirectiveLocationEnum                 = DirectiveLocations.Register("ENUM")
	DirectiveLocationEnumValue            = DirectiveLocations.Register("ENUM_VALUE")
	DirectiveLocationInputObject          = DirectiveLocations.Register("INPUT_OBJECT")
	DirectiveLocationInputFieldDefinition = DirectiveLocations.Register("INPUT_FIELD_DEFINITION")
)
View Source
var CurrentSchemaInput = ImplicitInput{
	Name: "cachePerSchema",
	Resolver: func(ctx context.Context, _ map[string]Input) (Input, error) {
		srv := CurrentDagqlServer(ctx)
		if srv == nil {
			return nil, fmt.Errorf("current dagql server not found")
		}
		return NewString(srv.SchemaDigest().String()), nil
	},
}

CurrentSchemaInput scopes a call ID to the schema digest of the dagql server currently executing the call.

View Source
var DirectiveLocations = NewEnum[DirectiveLocation]()
View Source
var ErrCacheRecursiveCall = fmt.Errorf("recursive call detected")
View Source
var ErrPersistStateNotReady = errors.New("persist state not ready")
View Source
var PerCallInput = ImplicitInput{
	Name: "cachePerCall",
	Resolver: func(context.Context, map[string]Input) (Input, error) {
		return NewString(identity.NewID()), nil
	},
}

PerCallInput scopes a call ID per invocation by mixing in a random value as an implicit call input.

View Source
var PerClientInput = ImplicitInput{
	Name: "cachePerClient",
	Resolver: func(ctx context.Context, _ map[string]Input) (Input, error) {
		clientMD, err := engine.ClientMetadataFromContext(ctx)
		if err != nil {
			return nil, fmt.Errorf("failed to get client metadata: %w", err)
		}
		if clientMD.ClientID == "" {
			return nil, fmt.Errorf("client ID not found in context")
		}
		return NewString(clientMD.ClientID), nil
	},
}

PerClientInput scopes a call ID per client by mixing in the client ID as an implicit call input.

View Source
var PerSessionInput = ImplicitInput{
	Name: "cachePerSession",
	Resolver: func(ctx context.Context, _ map[string]Input) (Input, error) {
		clientMD, err := engine.ClientMetadataFromContext(ctx)
		if err != nil {
			return nil, fmt.Errorf("failed to get client metadata: %w", err)
		}
		if clientMD.SessionID == "" {
			return nil, fmt.Errorf("session ID not found in context")
		}
		return NewString(clientMD.SessionID), nil
	},
}

PerSessionInput scopes a call ID per session by mixing in the session ID as an implicit call input.

Functions

func ArbitraryValueFunc added in v0.20.0

func ArbitraryValueFunc(v any) func(context.Context) (any, error)

func ContextWithCache added in v0.21.0

func ContextWithCache(ctx context.Context, cache *Cache) context.Context

func ContextWithCall added in v0.21.0

func ContextWithCall(ctx context.Context, call *ResultCall) context.Context

func ContextWithOperationLeaseProvider added in v0.21.0

func ContextWithOperationLeaseProvider(ctx context.Context, provider OperationLeaseProvider) context.Context

func ContextWithTrivialField added in v0.21.0

func ContextWithTrivialField(ctx context.Context) context.Context

func CurrentFieldIsTrivial added in v0.21.0

func CurrentFieldIsTrivial(ctx context.Context) bool

func FormatDescription

func FormatDescription(paras ...string) string

func HasPendingLazyEvaluation added in v0.21.0

func HasPendingLazyEvaluation(res AnyResult) bool

func IDTypeNameFor added in v0.9.8

func IDTypeNameFor(t Typed) string

func IDTypeNameForRawType added in v0.18.6

func IDTypeNameForRawType(t string) string

func IsInternal added in v0.10.0

func IsInternal(ctx context.Context) bool

IsInternal returns whether the internal flag is set in the context.

func IsSkipped added in v0.18.13

func IsSkipped(ctx context.Context) bool

func LoadIDs

func LoadIDs[T Typed](ctx context.Context, srv *Server, ids []ID[T]) ([]T, error)

func NewDefaultHandler added in v0.15.4

func NewDefaultHandler(es graphql.ExecutableSchema) *handler.Server

func NoopDone added in v0.11.0

func NoopDone(res AnyResult, cached bool, rerr *error)

func RemoveCachePersistenceStore added in v0.21.0

func RemoveCachePersistenceStore(dbPath string) error

func ShouldEmitTelemetry added in v0.21.0

func ShouldEmitTelemetry(ctx context.Context, store TelemetrySeenKeyStore, callKey string, doNotCache bool) bool

func TraceEGraphDebug added in v0.21.0

func TraceEGraphDebug(ctx context.Context, event string, args ...any)

func Tracer added in v0.11.0

func Tracer(ctx context.Context) trace.Tracer

func UnwrapAs added in v0.16.2

func UnwrapAs[T any](val any) (T, bool)

UnwrapAs attempts casting val to T, unwrapping as necessary.

NOTE: the order of operations is important here - it's important to first check compatibility with T before unwrapping, since sometimes T also implements Wrapper.

func ValueFunc added in v0.20.0

func ValueFunc(v AnyResult) func(context.Context) (AnyResult, error)

func WithNonInternalTelemetry added in v0.19.7

func WithNonInternalTelemetry(ctx context.Context) context.Context

WithNonInternalTelemetry marks telemetry within the context as non-internal, so that Server.Select does not mark its spans internal.

func WithRepeatedTelemetry added in v0.18.11

func WithRepeatedTelemetry(ctx context.Context) context.Context

WithRepeatedTelemetry resets the state of seen cache keys so that we emit telemetry for spans that we've already seen within the session.

This is useful in scenarios where we want to see actions performed, even if they had been performed already (e.g. an LLM running tools).

Additionally, it explicitly sets the internal flag to false, to prevent Server.Select from marking its spans internal.

func WithSkip added in v0.18.13

func WithSkip(ctx context.Context) context.Context

Types

type AllView added in v0.12.0

type AllView struct{}

AllView is similar to the global view, however, instead of being an empty view, it's still counted as a view.

This means that each call for a field is associated with the server view, which results in slightly different caching behavior. Additionally, it can be overridden in different views.

func (AllView) Contains added in v0.12.0

func (AllView) Contains(view call.View) bool

type AnyObjectResult added in v0.18.13

type AnyObjectResult interface {
	AnyResult

	// ObjectType returns the type of the object.
	ObjectType() ObjectType

	// Receiver resolves the object result referenced by this result call's receiver, if any.
	Receiver(context.Context, *Server) (AnyObjectResult, error)

	// Select evaluates the field selected by the given selector and returns the result.
	//
	// The returned value is the raw Typed value returned from the field; it must
	// be instantiated with a class for further selection.
	//
	// Any Nullable values are automatically unwrapped.
	Select(context.Context, *Server, Selector) (AnyResult, error)
}

AnyObjectResult is an AnyResult that wraps a selectable value (i.e. a graph object)

type AnyResult added in v0.18.13

type AnyResult interface {
	Typed
	Wrapper
	IDable
	RecipeIDable
	Setter

	// RecipeDigest returns the semantic recipe digest of the value.
	RecipeDigest(context.Context) (digest.Digest, error)

	// DerefValue returns an AnyResult when the wrapped value is Derefable and
	// has a value set. If the value is not derefable, it returns itself.
	DerefValue() (AnyResult, bool)

	// NthValue returns the Nth value of the wrapped value when the wrapped value
	// is an Enumerable. If the wrapped value is not Enumerable, it returns an error.
	NthValue(context.Context, int) (AnyResult, error)

	// NullableWrapped returns a nullable view over the same underlying result.
	NullableWrapped() AnyResult

	// WithContentDigest returns a new AnyResult with the given content digest.
	WithContentDigestAny(context.Context, digest.Digest) (AnyResult, error)
	// WithSessionResourceHandle returns a new AnyResult with the given session resource handle.
	WithSessionResourceHandleAny(context.Context, SessionResourceHandle) (AnyResult, error)

	HitCache() bool
	ResultCall() (*ResultCall, error)
	// contains filtered or unexported methods
}

AnyResult is a Typed value wrapped with an ID constructor. The wrapped value may be any graphql type, including scalars, objects, arrays, etc. It's a Result but as an interface and without any type params, allowing it to be passed around without knowing the concrete type at compile-time.

type ArbitraryCachedResult added in v0.20.0

type ArbitraryCachedResult interface {
	Value() any
	HitCache() bool
}

type Argument added in v0.18.6

type Argument struct {
	Spec InputSpec
}

func Arg added in v0.18.6

func Arg(name string) Argument

func (Argument) Default added in v0.18.6

func (arg Argument) Default(input Input) Argument

func (Argument) Deprecated added in v0.18.6

func (arg Argument) Deprecated(paras ...string) Argument

func (Argument) Doc added in v0.18.6

func (arg Argument) Doc(paras ...string) Argument

func (Argument) Experimental added in v0.18.6

func (arg Argument) Experimental(paras ...string) Argument

func (Argument) Internal added in v0.18.11

func (arg Argument) Internal() Argument

func (Argument) Sensitive added in v0.18.6

func (arg Argument) Sensitive() Argument

func (Argument) View added in v0.18.6

func (arg Argument) View(view ViewFilter) Argument

type AroundFunc

type AroundFunc func(
	context.Context,
	*CallRequest,
) (context.Context, func(res AnyResult, cached bool, err *error))

AroundFunc is a function that is called around every non-cached selection.

It's a little funny looking. I may have goofed it. This will be cleaned up soon.

type Array

type Array[T Typed] []T

Array is an array of GraphQL values.

func MapArrayInput

func MapArrayInput[T Input, R Typed](opt ArrayInput[T], fn func(T) (R, error)) (Array[R], error)

func NewBoolArray

func NewBoolArray(elems ...bool) Array[Boolean]

func NewBooleanArray added in v0.18.13

func NewBooleanArray(elems ...bool) Array[Boolean]

func NewFloatArray

func NewFloatArray[T constraints.Float](elems ...T) Array[Float]

func NewIntArray

func NewIntArray[T constraints.Integer](elems ...T) Array[Int]

func NewStringArray

func NewStringArray(elems ...string) Array[String]

func ToArray

func ToArray[A any, T Typed](fn func(A) T, elems ...A) Array[T]

ToArray creates a new Array by applying the given function to each element of the given slice.

func (Array[T]) Element added in v0.16.3

func (arr Array[T]) Element() Typed

func (Array[T]) Len

func (arr Array[T]) Len() int

func (Array[T]) Nth

func (arr Array[T]) Nth(i int) (Typed, error)

func (Array[T]) NthValue added in v0.18.13

func (arr Array[T]) NthValue(i int, call *ResultCall) (AnyResult, error)

func (Array[T]) Type

func (i Array[T]) Type() *ast.Type

type ArrayInput

type ArrayInput[I Input] []I

Array is an array of GraphQL values.

func (ArrayInput[I]) DecodeInput

func (a ArrayInput[I]) DecodeInput(val any) (Input, error)

func (ArrayInput[S]) Decoder

func (a ArrayInput[S]) Decoder() InputDecoder

func (ArrayInput[I]) SetField

func (d ArrayInput[I]) SetField(val reflect.Value) error

func (ArrayInput[S]) ToArray

func (a ArrayInput[S]) ToArray() Array[S]

func (ArrayInput[S]) ToLiteral

func (i ArrayInput[S]) ToLiteral() call.Literal

func (ArrayInput[S]) Type

func (a ArrayInput[S]) Type() *ast.Type

type Boolean

type Boolean bool

Boolean is a GraphQL Boolean scalar.

func NewBoolean

func NewBoolean(val bool) Boolean

func (Boolean) Bool

func (b Boolean) Bool() bool

func (Boolean) DecodeInput

func (Boolean) DecodeInput(val any) (Input, error)

func (Boolean) Decoder

func (Boolean) Decoder() InputDecoder

func (Boolean) MarshalJSON

func (b Boolean) MarshalJSON() ([]byte, error)

func (Boolean) SetField

func (b Boolean) SetField(v reflect.Value) error

func (Boolean) ToLiteral

func (b Boolean) ToLiteral() call.Literal

func (Boolean) Type

func (Boolean) Type() *ast.Type

func (Boolean) TypeDefinition

func (b Boolean) TypeDefinition(view call.View) *ast.Definition

func (Boolean) TypeName

func (Boolean) TypeName() string

func (*Boolean) UnmarshalJSON

func (b *Boolean) UnmarshalJSON(p []byte) error

type Cache

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

func EngineCache added in v0.21.0

func EngineCache(ctx context.Context) (*Cache, error)

func NewCache

func NewCache(
	ctx context.Context,
	dbPath string,
	snapshotManager bkcache.SnapshotManager,
	snapshotGC func(context.Context) error,
) (*Cache, error)

func (*Cache) AddExplicitDependency added in v0.21.0

func (c *Cache) AddExplicitDependency(ctx context.Context, parent AnyResult, dep AnyResult, reason string) error

func (*Cache) AttachResult added in v0.21.0

func (c *Cache) AttachResult(ctx context.Context, sessionID string, resolver TypeResolver, res AnyResult) (AnyResult, error)

func (*Cache) BindSessionResource added in v0.21.0

func (c *Cache) BindSessionResource(_ context.Context, sessionID string, clientID string, handle SessionResourceHandle, value any) error

func (*Cache) Close added in v0.21.0

func (c *Cache) Close(ctx context.Context) error

func (*Cache) CloseDiscardingPersistence added in v0.21.0

func (c *Cache) CloseDiscardingPersistence() error

func (*Cache) DebugEGraphSnapshot added in v0.21.0

func (c *Cache) DebugEGraphSnapshot() *EGraphDebugSnapshot

func (*Cache) EntryStats added in v0.20.0

func (c *Cache) EntryStats() CacheEntryStats

func (*Cache) Evaluate added in v0.21.0

func (c *Cache) Evaluate(ctx context.Context, results ...AnyResult) error

func (*Cache) GetOrInitArbitrary added in v0.20.0

func (c *Cache) GetOrInitArbitrary(
	ctx context.Context,
	sessionID string,
	callKey string,
	fn func(context.Context) (any, error),
) (ArbitraryCachedResult, error)

func (*Cache) GetOrInitCall added in v0.20.0

func (c *Cache) GetOrInitCall(
	ctx context.Context,
	sessionID string,
	resolver TypeResolver,
	req *CallRequest,
	fn func(context.Context) (AnyResult, error),
) (AnyResult, error)

Core cache lookup/insert flow is intentionally centralized here.

func (*Cache) LoadPersistedObjectByResultID added in v0.21.0

func (c *Cache) LoadPersistedObjectByResultID(ctx context.Context, dag *Server, resultID uint64) (AnyObjectResult, error)

func (*Cache) LoadResultByResultID added in v0.21.0

func (c *Cache) LoadResultByResultID(ctx context.Context, sessionID string, dag *Server, resultID uint64) (AnyResult, error)

func (*Cache) MakeResultUnpruneable added in v0.21.0

func (c *Cache) MakeResultUnpruneable(ctx context.Context, res AnyResult) error

func (*Cache) PersistedResultID added in v0.21.0

func (c *Cache) PersistedResultID(res AnyResult) (uint64, error)

func (*Cache) PersistedSnapshotLinksByResultID added in v0.21.0

func (c *Cache) PersistedSnapshotLinksByResultID(ctx context.Context, resultID uint64) ([]PersistedSnapshotRefLink, error)

func (*Cache) PersistenceResetReason added in v0.21.0

func (c *Cache) PersistenceResetReason() CachePersistenceResetReason

func (*Cache) Prune added in v0.21.0

func (c *Cache) Prune(ctx context.Context, policies []CachePrunePolicy) (CachePruneReport, error)

func (*Cache) RecipeDigestForCall added in v0.21.0

func (c *Cache) RecipeDigestForCall(frame *ResultCall) (digest.Digest, error)

func (*Cache) RecipeIDForCall added in v0.21.0

func (c *Cache) RecipeIDForCall(ctx context.Context, frame *ResultCall) (*call.ID, error)

func (*Cache) ReleaseSession added in v0.21.0

func (c *Cache) ReleaseSession(ctx context.Context, sessionID string) error

func (*Cache) ResolveSessionResource added in v0.21.0

func (c *Cache) ResolveSessionResource(
	ctx context.Context,
	sessionID string,
	clientID string,
	handle SessionResourceHandle,
) (any, error)

func (*Cache) ResolveSessionResourceCandidates added in v0.21.0

func (c *Cache) ResolveSessionResourceCandidates(
	_ context.Context,
	sessionID string,
	clientID string,
	handle SessionResourceHandle,
) ([]SessionResourceCandidate, error)

func (*Cache) ResultCallByResultID added in v0.21.0

func (c *Cache) ResultCallByResultID(ctx context.Context, sessionID string, resultID uint64) (*ResultCall, error)

func (*Cache) ResultInstallSpans added in v0.21.0

func (c *Cache) ResultInstallSpans(sessionID string, res AnyResult) []trace.SpanContext

ResultInstallSpans returns install span contexts recorded for res in the given session — i.e. the API spans whose call returned (or owns) this result. Used to attribute later runtime failures (e.g. a service exiting early) back to the API span that installed the value.

func (*Cache) Size added in v0.20.0

func (c *Cache) Size() int

func (*Cache) SyncResultSnapshotOwnerLeases added in v0.21.0

func (c *Cache) SyncResultSnapshotOwnerLeases(ctx context.Context, res AnyResult) error

func (*Cache) TeachCallEquivalentToResult added in v0.21.0

func (c *Cache) TeachCallEquivalentToResult(ctx context.Context, sessionID string, frame *ResultCall, res AnyResult) error

func (*Cache) TeachContentDigest added in v0.21.0

func (c *Cache) TeachContentDigest(ctx context.Context, res AnyResult, contentDigest digest.Digest) error

func (*Cache) UsageEntriesAll added in v0.21.0

func (c *Cache) UsageEntriesAll(ctx context.Context) []CacheUsageEntry

func (*Cache) WalkResultCall added in v0.21.0

func (c *Cache) WalkResultCall(rootCall *ResultCall, visit func(*ResultCallRef, *ResultCall) error) error

func (*Cache) WriteDebugCacheSnapshot added in v0.21.0

func (c *Cache) WriteDebugCacheSnapshot(w io.Writer) error

type CacheDebugArbitraryCall added in v0.21.0

type CacheDebugArbitraryCall struct {
	CallKey           string `json:"call_key"`
	Waiters           int    `json:"waiters"`
	OwnerSessionCount int    `json:"owner_session_count"`
	Completed         bool   `json:"completed"`
	HasValue          bool   `json:"has_value"`
	ValueType         string `json:"value_type,omitempty"`
	Error             string `json:"error,omitempty"`
}

type CacheDebugOngoingCall added in v0.21.0

type CacheDebugOngoingCall struct {
	CallKey           string `json:"call_key"`
	ConcurrencyKey    string `json:"concurrency_key,omitempty"`
	Waiters           int    `json:"waiters"`
	IsPersistable     bool   `json:"is_persistable"`
	TTLSeconds        int64  `json:"ttl_seconds,omitempty"`
	Completed         bool   `json:"completed"`
	Error             string `json:"error,omitempty"`
	SharedResultID    uint64 `json:"shared_result_id,omitempty"`
	ResultDescription string `json:"result_description,omitempty"`
	ResultRecordType  string `json:"result_record_type,omitempty"`
	ResultTypeName    string `json:"result_type_name,omitempty"`
}

type CacheDebugResult added in v0.21.0

type CacheDebugResult struct {
	EGraphDebugResult
	ResultCall                            *ResultCall      `json:"result_call,omitempty"`
	ResultCallRecipeDigest                string           `json:"result_call_recipe_digest,omitempty"`
	ResultCallRecipeDigestError           string           `json:"result_call_recipe_digest_error,omitempty"`
	ResultCallContentPreferredDigest      string           `json:"result_call_content_preferred_digest,omitempty"`
	ResultCallContentPreferredDigestError string           `json:"result_call_content_preferred_digest_error,omitempty"`
	ResultCallInputDigests                []string         `json:"result_call_input_digests,omitempty"`
	ResultCallInputDigestsError           string           `json:"result_call_input_digests_error,omitempty"`
	AssociatedTermIDs                     []uint64         `json:"associated_term_ids,omitempty"`
	IndexedDigests                        []string         `json:"indexed_digests,omitempty"`
	ExpiresAtUnix                         int64            `json:"expires_at_unix,omitempty"`
	CreatedAtUnixNano                     int64            `json:"created_at_unix_nano,omitempty"`
	LastUsedAtUnixNano                    int64            `json:"last_used_at_unix_nano,omitempty"`
	CacheUsageSizeByIdentity              map[string]int64 `json:"cache_usage_size_by_identity,omitempty"`
	PersistedEnvelopeKind                 string           `json:"persisted_envelope_kind,omitempty"`
	PersistedEnvelopeTypeName             string           `json:"persisted_envelope_type_name,omitempty"`
}

type CacheDebugResultDigestIndex added in v0.21.0

type CacheDebugResultDigestIndex struct {
	Digest          string   `json:"digest"`
	SharedResultIDs []uint64 `json:"shared_result_ids"`
}

type CacheDebugSessionResults added in v0.21.0

type CacheDebugSessionResults struct {
	SessionID       string   `json:"session_id"`
	SharedResultIDs []uint64 `json:"shared_result_ids"`
}

type CacheDebugSnapshot added in v0.21.0

type CacheDebugSnapshot struct {
	TraceFormatVersion      int                           `json:"trace_format_version"`
	BootID                  string                        `json:"boot_id"`
	CapturedAtSeq           uint64                        `json:"captured_at_seq"`
	CapturedAtTime          string                        `json:"captured_at_time"`
	SessionResults          []CacheDebugSessionResults    `json:"session_results,omitempty"`
	Results                 []CacheDebugResult            `json:"results"`
	ResultDigestIndexes     []CacheDebugResultDigestIndex `json:"result_digest_indexes"`
	Terms                   []EGraphDebugTerm             `json:"terms"`
	ResultTerms             []EGraphDebugResultTerm       `json:"result_terms"`
	Digests                 []EGraphDebugDigestMapping    `json:"digests"`
	EqClasses               []EGraphDebugEqClass          `json:"eq_classes"`
	OngoingCalls            []CacheDebugOngoingCall       `json:"ongoing_calls,omitempty"`
	OngoingArbitraryCalls   []CacheDebugArbitraryCall     `json:"ongoing_arbitrary_calls,omitempty"`
	CompletedArbitraryCalls []CacheDebugArbitraryCall     `json:"completed_arbitrary_calls,omitempty"`
}

type CacheEntryStats added in v0.20.0

type CacheEntryStats struct {
	OngoingCalls            int
	CompletedCalls          int
	RetainedCalls           int
	CompletedCallsByContent int
	OngoingArbitrary        int
	CompletedArbitrary      int
}

type CachePersistenceResetReason added in v0.21.0

type CachePersistenceResetReason string
const (
	CachePersistenceResetNone            CachePersistenceResetReason = ""
	CachePersistenceResetSchemaMismatch  CachePersistenceResetReason = "schema_mismatch"
	CachePersistenceResetUncleanShutdown CachePersistenceResetReason = "unclean_shutdown"
	CachePersistenceResetImportFailure   CachePersistenceResetReason = "import_failure"
)

type CachePrunePolicy added in v0.21.0

type CachePrunePolicy struct {
	All           bool
	Filters       []string
	KeepDuration  time.Duration
	ReservedSpace int64
	MaxUsedSpace  int64
	MinFreeSpace  int64
	TargetSpace   int64

	// CurrentFreeSpace is optional available-disk bytes at prune start used to
	// evaluate MinFreeSpace. When unset, MinFreeSpace behaves as if free space
	// were zero.
	CurrentFreeSpace int64
}

type CachePruneReport added in v0.21.0

type CachePruneReport struct {
	Entries        []CacheUsageEntry
	ReclaimedBytes int64
}

type CacheUsageEntry added in v0.21.0

type CacheUsageEntry struct {
	ID                        string
	Description               string
	RecordType                string
	RecordTypes               []string
	DagqlCall                 string
	SizeBytes                 int64
	CreatedTimeUnixNano       int64
	MostRecentUseTimeUnixNano int64
	ActivelyUsed              bool
}

type CallRequest added in v0.21.0

type CallRequest struct {
	*ResultCall

	ConcurrencyKey string
	TTL            int64
	DoNotCache     bool
	IsPersistable  bool
}

CallRequest is the mutable planning-time wrapper around the semantic ResultCall shape, plus request-only cache policy that does not belong in persisted provenance.

func (*CallRequest) Arg added in v0.21.0

func (req *CallRequest) Arg(name string) *ResultCallArg

func (*CallRequest) Clone added in v0.21.0

func (req *CallRequest) Clone() *CallRequest

func (*CallRequest) DeleteArg added in v0.21.0

func (req *CallRequest) DeleteArg(name string)

func (*CallRequest) HasArg added in v0.21.0

func (req *CallRequest) HasArg(name string) bool

func (*CallRequest) SetArg added in v0.21.0

func (req *CallRequest) SetArg(arg *ResultCallArg)

func (*CallRequest) SetArgInput added in v0.21.0

func (req *CallRequest) SetArgInput(ctx context.Context, name string, input Input, sensitive bool) error

func (*CallRequest) ToResultCall added in v0.21.0

func (req *CallRequest) ToResultCall() (*ResultCall, error)

type Class

type Class[T Typed] struct {
	// contains filtered or unexported fields
}

Class is a class of Object types.

The class is defined by a set of fields, which are installed into the class dynamically at runtime.

func NewClass

func NewClass[T Typed](srv *Server, opts_ ...ClassOpts[T]) Class[T]

NewClass returns a new empty class for a given type.

func (Class[T]) Extend

func (class Class[T]) Extend(spec FieldSpec, fun FieldFunc)

func (Class[T]) ExtendLoadByID added in v0.21.0

func (class Class[T]) ExtendLoadByID(spec FieldSpec, fun LoadByIDFunc)

func (Class[T]) Field

func (class Class[T]) Field(name string, view call.View) (Field[T], bool)

func (Class[T]) FieldSpec added in v0.16.2

func (class Class[T]) FieldSpec(name string, view call.View) (FieldSpec, bool)

func (Class[T]) FieldSpecs added in v0.20.4

func (class Class[T]) FieldSpecs(view call.View) []FieldSpec

func (Class[T]) ForkObjectType added in v0.21.0

func (class Class[T]) ForkObjectType(srv *Server) (ObjectType, error)

func (Class[T]) IDType

func (class Class[T]) IDType() (IDType, bool)

func (Class[T]) Install

func (class Class[T]) Install(fields ...Field[T])

func (Class[T]) New

func (class Class[T]) New(val AnyResult) (AnyObjectResult, error)

New returns a new instance of the class.

func (Class[T]) ParseField

func (class Class[T]) ParseField(ctx context.Context, view call.View, astField *ast.Field, vars map[string]any) (Selector, *ast.Type, error)

ParseField parses a field selection into a Selector and return type.

func (Class[T]) TypeDefinition

func (class Class[T]) TypeDefinition(view call.View) *ast.Definition

TypeDefinition returns the schema definition of the class.

The definition is derived from the type name, description, and fields. The type may implement Definitive or Descriptive to provide more information.

Each currently defined field is installed on the returned definition.

func (Class[T]) TypeName

func (class Class[T]) TypeName() string

func (Class[T]) Typed

func (class Class[T]) Typed() Typed

type ClassOpts

type ClassOpts[T Typed] struct {
	// NoIDs disables the default "id" field and disables the IDType method.
	NoIDs bool

	// Typed contains the Typed value whose Type() determines the class's type.
	//
	// In the simple case, we can just use a zero-value, but it is also allowed
	// to use a dynamic Typed value.
	Typed T

	// The inner type sourceMap directive so additional type
	// registered by the engine can store also store its origin.
	SourceMap *ast.Directive
}

type DecoderFunc

type DecoderFunc func(any) (Input, error)

func (DecoderFunc) DecodeInput

func (f DecoderFunc) DecodeInput(val any) (Input, error)

type Definitive

type Definitive interface {
	TypeDefinition(view call.View) *ast.Definition
}

Definitive is a type that knows how to define itself in the schema.

type DependencyResult added in v0.21.0

type DependencyResult struct {
	Result AnyResult
	// Owned is true when the parent's install span should also be attributed
	// to this dep for lazy failure causality. False marks the edge as
	// liveness-only — the dep is kept alive by the parent and preflighted
	// before the parent's lazy callback, but failures in the dep do not
	// short-circuit attribution onto the parent's install span.
	Owned bool
}

DependencyResult is an attached dependency result with a kind flag.

type Derefable

type Derefable interface {
	Deref() (Typed, bool)
}

Derefable is a type that wraps another type.

In practice this is only used for Optional and Nullable. It should be used sparingly, since wrapping interfaces explodes very quickly.

type DerefableResult added in v0.18.13

type DerefableResult interface {
	Derefable
	DerefToResult(call *ResultCall) (AnyResult, bool)
}

DerefableResult is a Derefable that can return a result underlied by the specific type the Derefable wraps.

type Descriptive

type Descriptive interface {
	TypeDescription() string
}

Descriptive is an interface for types that have a description.

The description is used in the schema. To provide a full definition, implement Definitive instead.

type DigestedSerializedString added in v0.21.0

type DigestedSerializedString[T any] struct {
	Self   T
	Digest digest.Digest
}

func NewDigestedSerializedString added in v0.21.0

func NewDigestedSerializedString[T any](val T, dig digest.Digest) DigestedSerializedString[T]

func (DigestedSerializedString[T]) DecodeInput added in v0.21.0

func (DigestedSerializedString[T]) DecodeInput(val any) (Input, error)

func (DigestedSerializedString[T]) Decoder added in v0.21.0

func (s DigestedSerializedString[T]) Decoder() InputDecoder

func (DigestedSerializedString[T]) MarshalJSON added in v0.21.0

func (s DigestedSerializedString[T]) MarshalJSON() ([]byte, error)

func (DigestedSerializedString[T]) SetField added in v0.21.0

func (s DigestedSerializedString[T]) SetField(v reflect.Value) error

func (DigestedSerializedString[T]) String added in v0.21.0

func (s DigestedSerializedString[T]) String() string

func (DigestedSerializedString[T]) ToLiteral added in v0.21.0

func (s DigestedSerializedString[T]) ToLiteral() call.Literal

func (DigestedSerializedString[T]) Type added in v0.21.0

func (DigestedSerializedString[T]) Type() *ast.Type

func (*DigestedSerializedString[T]) UnmarshalJSON added in v0.21.0

func (s *DigestedSerializedString[T]) UnmarshalJSON(p []byte) error

type DirectiveLocation

type DirectiveLocation string

func (DirectiveLocation) Decoder

func (DirectiveLocation) Decoder() InputDecoder

func (DirectiveLocation) ToLiteral

func (d DirectiveLocation) ToLiteral() call.Literal

func (DirectiveLocation) Type

func (DirectiveLocation) Type() *ast.Type

type DirectiveSpec

type DirectiveSpec struct {
	Name         string              `field:"true"`
	Description  string              `field:"true"`
	Args         InputSpecs          `field:"true"`
	Locations    []DirectiveLocation `field:"true"`
	IsRepeatable bool                `field:"true"`
}

func (DirectiveSpec) DirectiveDefinition

func (d DirectiveSpec) DirectiveDefinition(view call.View) *ast.DirectiveDefinition

type DynamicArrayInput

type DynamicArrayInput struct {
	Elem   Input
	Values []Input
}

func (DynamicArrayInput) DecodeInput

func (d DynamicArrayInput) DecodeInput(val any) (Input, error)

func (DynamicArrayInput) Decoder

func (d DynamicArrayInput) Decoder() InputDecoder

func (DynamicArrayInput) Element added in v0.16.3

func (d DynamicArrayInput) Element() Typed

func (DynamicArrayInput) Len

func (d DynamicArrayInput) Len() int

func (DynamicArrayInput) Nth

func (d DynamicArrayInput) Nth(i int) (Typed, error)

func (DynamicArrayInput) NthValue added in v0.18.13

func (d DynamicArrayInput) NthValue(i int, call *ResultCall) (AnyResult, error)

func (DynamicArrayInput) SetField

func (d DynamicArrayInput) SetField(val reflect.Value) error

func (DynamicArrayInput) ToLiteral

func (d DynamicArrayInput) ToLiteral() call.Literal

func (DynamicArrayInput) Type

func (d DynamicArrayInput) Type() *ast.Type

type DynamicArrayOutput

type DynamicArrayOutput struct {
	Elem   Typed
	Values []Typed
}

func (DynamicArrayOutput) Element added in v0.16.3

func (d DynamicArrayOutput) Element() Typed

func (DynamicArrayOutput) Len

func (d DynamicArrayOutput) Len() int

func (DynamicArrayOutput) MarshalJSON

func (d DynamicArrayOutput) MarshalJSON() ([]byte, error)

func (DynamicArrayOutput) Nth

func (d DynamicArrayOutput) Nth(i int) (Typed, error)

func (DynamicArrayOutput) NthValue added in v0.18.13

func (d DynamicArrayOutput) NthValue(i int, call *ResultCall) (AnyResult, error)

func (DynamicArrayOutput) SetField added in v0.9.9

func (d DynamicArrayOutput) SetField(val reflect.Value) error

func (DynamicArrayOutput) Type

func (d DynamicArrayOutput) Type() *ast.Type

type DynamicInputFunc added in v0.21.0

type DynamicInputFunc[T Typed, A any] func(
	context.Context,
	ObjectResult[T],
	A,
	*CallRequest,
) error

type DynamicNullable

type DynamicNullable struct {
	Elem  Typed
	Value Typed
	Valid bool
}

func (DynamicNullable) Deref

func (n DynamicNullable) Deref() (Typed, bool)

func (DynamicNullable) DerefToResult added in v0.18.13

func (n DynamicNullable) DerefToResult(
	call *ResultCall,
) (AnyResult, bool)

func (DynamicNullable) MarshalJSON

func (n DynamicNullable) MarshalJSON() ([]byte, error)

func (DynamicNullable) Type

func (n DynamicNullable) Type() *ast.Type

func (*DynamicNullable) UnmarshalJSON

func (n *DynamicNullable) UnmarshalJSON(p []byte) error

type DynamicOptional

type DynamicOptional struct {
	Elem  Input
	Value Input
	Valid bool
}

func (DynamicOptional) DecodeInput

func (o DynamicOptional) DecodeInput(val any) (Input, error)

func (DynamicOptional) Decoder

func (o DynamicOptional) Decoder() InputDecoder

func (DynamicOptional) Deref

func (o DynamicOptional) Deref() (Typed, bool)

func (DynamicOptional) MarshalJSON

func (o DynamicOptional) MarshalJSON() ([]byte, error)

func (DynamicOptional) SetField

func (o DynamicOptional) SetField(val reflect.Value) error

func (DynamicOptional) ToLiteral

func (o DynamicOptional) ToLiteral() call.Literal

func (DynamicOptional) Type

func (o DynamicOptional) Type() *ast.Type

func (*DynamicOptional) UnmarshalJSON added in v0.21.0

func (o *DynamicOptional) UnmarshalJSON(p []byte) error

func (DynamicOptional) Unwrap added in v0.19.7

func (o DynamicOptional) Unwrap() Typed

type DynamicResultArrayOutput added in v0.18.13

type DynamicResultArrayOutput struct {
	Elem   Typed
	Values []AnyResult
}

func (DynamicResultArrayOutput) AttachDependencyResults added in v0.21.0

func (d DynamicResultArrayOutput) AttachDependencyResults(
	_ context.Context,
	_ AnyResult,
	attach func(AnyResult) (AnyResult, error),
) ([]AnyResult, error)

func (DynamicResultArrayOutput) Element added in v0.18.13

func (d DynamicResultArrayOutput) Element() Typed

func (DynamicResultArrayOutput) Len added in v0.18.13

func (d DynamicResultArrayOutput) Len() int

func (DynamicResultArrayOutput) MarshalJSON added in v0.18.13

func (d DynamicResultArrayOutput) MarshalJSON() ([]byte, error)

func (DynamicResultArrayOutput) Nth added in v0.18.13

func (DynamicResultArrayOutput) NthValue added in v0.18.13

func (d DynamicResultArrayOutput) NthValue(i int, _ *ResultCall) (AnyResult, error)

func (DynamicResultArrayOutput) SetField added in v0.18.13

func (d DynamicResultArrayOutput) SetField(val reflect.Value) error

func (DynamicResultArrayOutput) Type added in v0.18.13

func (d DynamicResultArrayOutput) Type() *ast.Type

type EGraphDebugDigestMapping added in v0.21.0

type EGraphDebugDigestMapping struct {
	Digest    string `json:"digest"`
	EqClassID uint64 `json:"eq_class_id"`
}

type EGraphDebugEqClass added in v0.21.0

type EGraphDebugEqClass struct {
	EqClassID uint64   `json:"eq_class_id"`
	Digests   []string `json:"digests"`
}

type EGraphDebugInputProvenance added in v0.21.0

type EGraphDebugInputProvenance struct {
	Kind string `json:"kind"`
}

type EGraphDebugResult added in v0.21.0

type EGraphDebugResult struct {
	SharedResultID           uint64                     `json:"shared_result_id"`
	OutputEqClassIDs         []uint64                   `json:"output_eq_class_ids,omitempty"`
	RecordType               string                     `json:"record_type,omitempty"`
	Description              string                     `json:"description,omitempty"`
	TypeName                 string                     `json:"type_name,omitempty"`
	IncomingOwnershipCount   int64                      `json:"incoming_ownership_count"`
	HasValue                 bool                       `json:"has_value"`
	PayloadState             string                     `json:"payload_state"`
	HasPersistedEdge         bool                       `json:"has_persisted_edge"`
	PersistedEdgeUnpruneable bool                       `json:"persisted_edge_unpruneable"`
	ExplicitDeps             []uint64                   `json:"explicit_dep_ids,omitempty"`
	HeldDependencyResults    int                        `json:"held_dependency_results_count"`
	SnapshotLinks            []PersistedSnapshotRefLink `json:"snapshot_links,omitempty"`
}

type EGraphDebugResultTerm added in v0.21.0

type EGraphDebugResultTerm struct {
	SharedResultID  uint64                       `json:"shared_result_id"`
	TermID          uint64                       `json:"term_id"`
	InputProvenance []EGraphDebugInputProvenance `json:"input_provenance,omitempty"`
}

type EGraphDebugSnapshot added in v0.21.0

type EGraphDebugSnapshot struct {
	TraceFormatVersion int                        `json:"trace_format_version"`
	BootID             string                     `json:"boot_id"`
	CapturedAtSeq      uint64                     `json:"captured_at_seq"`
	CapturedAtTime     string                     `json:"captured_at_time"`
	Results            []EGraphDebugResult        `json:"results"`
	Terms              []EGraphDebugTerm          `json:"terms"`
	ResultTerms        []EGraphDebugResultTerm    `json:"result_terms"`
	Digests            []EGraphDebugDigestMapping `json:"digests"`
	EqClasses          []EGraphDebugEqClass       `json:"eq_classes"`
}

type EGraphDebugTerm added in v0.21.0

type EGraphDebugTerm struct {
	TermID     uint64   `json:"term_id"`
	SelfDigest string   `json:"self_digest"`
	InputEqIDs []uint64 `json:"input_eq_ids"`
	TermDigest string   `json:"term_digest"`
	OutputEqID uint64   `json:"output_eq_id"`
}

type EnumValue

type EnumValue[T enumValue] struct {
	Value       T
	Underlying  T
	Description string
	View        ViewFilter
}

type EnumValueName added in v0.13.6

type EnumValueName struct {
	Enum string
	Name string
}

func (*EnumValueName) DecodeInput added in v0.13.6

func (e *EnumValueName) DecodeInput(val any) (Input, error)

func (*EnumValueName) Decoder added in v0.13.6

func (e *EnumValueName) Decoder() InputDecoder

func (*EnumValueName) MarshalJSON added in v0.13.6

func (e *EnumValueName) MarshalJSON() ([]byte, error)

func (*EnumValueName) ToLiteral added in v0.13.6

func (e *EnumValueName) ToLiteral() call.Literal

func (*EnumValueName) Type added in v0.13.6

func (e *EnumValueName) Type() *ast.Type

func (*EnumValueName) TypeDefinition added in v0.13.6

func (e *EnumValueName) TypeDefinition(view call.View) *ast.Definition

func (*EnumValueName) TypeName added in v0.13.6

func (e *EnumValueName) TypeName() string

type EnumValues

type EnumValues[T enumValue] []EnumValue[T]

EnumValues is a list of possible values for an Enum.

func NewEnum

func NewEnum[T enumValue](vals ...T) *EnumValues[T]

NewEnum creates a new EnumType with the given possible values.

func (*EnumValues[T]) Alias added in v0.18.11

func (e *EnumValues[T]) Alias(val T, target T) T

func (*EnumValues[T]) AliasView added in v0.18.11

func (e *EnumValues[T]) AliasView(val T, target T, view ViewFilter) T

func (*EnumValues[T]) DecodeInput

func (e *EnumValues[T]) DecodeInput(val any) (Input, error)

func (*EnumValues[T]) Install

func (e *EnumValues[T]) Install(srv *Server)

func (*EnumValues[T]) Literal

func (e *EnumValues[T]) Literal(val T) call.Literal

func (*EnumValues[T]) Lookup

func (e *EnumValues[T]) Lookup(val string) (T, error)

func (*EnumValues[T]) PossibleValues

func (e *EnumValues[T]) PossibleValues(view call.View) ast.EnumValueList

func (*EnumValues[T]) Register

func (e *EnumValues[T]) Register(val T, desc ...string) T

func (*EnumValues[T]) RegisterView added in v0.18.11

func (e *EnumValues[T]) RegisterView(val T, view ViewFilter, desc ...string) T

func (*EnumValues[T]) Type

func (e *EnumValues[T]) Type() *ast.Type

func (*EnumValues[T]) TypeDefinition

func (e *EnumValues[T]) TypeDefinition(view call.View) *ast.Definition

func (*EnumValues[T]) TypeName

func (e *EnumValues[T]) TypeName() string

type Enumerable

type Enumerable interface {
	// Element returns the element of the Enumerable.
	Element() Typed
	// Len returns the number of elements in the Enumerable.
	Len() int
	// Nth returns the Nth element of the Enumerable, with 1 representing the
	// first entry.
	Nth(int) (Typed, error)

	NthValue(i int, call *ResultCall) (AnyResult, error)
}

Enumerable is a value that has a length and allows indexing.

type ExactView added in v0.12.0

type ExactView string

ExactView contains exactly one view.

func (ExactView) Contains added in v0.12.0

func (exact ExactView) Contains(view call.View) bool

type ExtendedError

type ExtendedError interface {
	error
	Extensions() map[string]any
}

ExtendedError is an error that can provide extra data in an error response.

type Field

type Field[T Typed] struct {
	Spec *FieldSpec
	Func func(context.Context, ObjectResult[T], map[string]Input, call.View) (AnyResult, error)
}

Field defines a field of an Object type.

func Func

func Func[T Typed, A any, R any](name string, fn FuncHandler[T, A, R]) Field[T]

Func is a helper for defining a field resolver and schema.

The function must accept a context.Context, the receiver, and a struct of arguments. All fields of the arguments struct must be Typed so that the schema may be derived, and Scalar to ensure a default value may be provided.

Arguments use struct tags to further configure the schema:

  • `name:"bar"` sets the name of the argument. By default this is the toLowerCamel'd field name.
  • `default:"foo"` sets the default value of the argument. The Scalar type determines how this value is parsed.
  • `doc:"..."` sets the description of the argument.

The function must return a Typed value, and an error.

To configure a description for the field in the schema, call .Doc on the result.

func FuncWithDynamicInputs added in v0.21.0

func FuncWithDynamicInputs[T Typed, A any, R any](
	name string,
	fn FuncHandler[T, A, R],
	cacheFn DynamicInputFunc[T, A],
) Field[T]

FuncWithDynamicInputs is like Func but lets a resolver customize request/cache behavior for each call (for example argument rewrites, TTL, do-not-cache, or concurrency key).

func NodeFunc

func NodeFunc[T Typed, A any, R any](name string, fn NodeFuncHandler[T, A, R]) Field[T]

NodeFunc is the same as Func, except it passes the ObjectResult instead of the receiver so that you can access its ID.

func NodeFuncWithDynamicInputs added in v0.21.0

func NodeFuncWithDynamicInputs[T Typed, A any, R any](
	name string,
	fn NodeFuncHandler[T, A, R],
	cacheFn DynamicInputFunc[T, A],
) Field[T]

NodeFuncWithDynamicInputs is like NodeFunc but lets a resolver customize request/cache behavior for each call (for example argument rewrites, TTL, do-not-cache, or concurrency key).

func (Field[T]) Args added in v0.18.6

func (field Field[T]) Args(args ...Argument) Field[T]

func (Field[T]) Deprecated

func (field Field[T]) Deprecated(paras ...string) Field[T]

Deprecated marks the field as deprecated, meaning it should not be used by new code.

func (Field[T]) DoNotCache added in v0.16.3

func (field Field[T]) DoNotCache(reason string, paras ...string) Field[T]

DoNotCache marks the field as not to be stored in the cache for the given reason why

func (Field[T]) Doc

func (field Field[T]) Doc(paras ...string) Field[T]

Doc sets the description of the field. Each argument is joined by two empty lines.

func (Field[T]) Experimental added in v0.18.4

func (field Field[T]) Experimental(paras ...string) Field[T]

Deprecated marks the field as experimental

func (Field[T]) Extend added in v0.12.0

func (field Field[T]) Extend() Field[T]

func (Field[T]) FieldDefinition

func (field Field[T]) FieldDefinition(view call.View) *ast.FieldDefinition

FieldDefinition returns the schema definition of the field.

func (Field[T]) IsPersistable added in v0.21.0

func (field Field[T]) IsPersistable() Field[T]

func (Field[T]) Sensitive added in v0.16.2

func (field Field[T]) Sensitive() Field[T]

func (Field[T]) View added in v0.12.0

func (field Field[T]) View(view ViewFilter) Field[T]

View sets a view for this field.

func (Field[T]) WithInput added in v0.21.0

func (field Field[T]) WithInput(inputs ...ImplicitInput) Field[T]

type FieldFunc

type FieldFunc func(context.Context, AnyResult, map[string]Input) (AnyResult, error)

FieldFunc is a function that implements a field on an object while limited to the object's external interface.

type FieldSpec

type FieldSpec struct {
	// Name is the name of the field.
	Name string
	// Description is the description of the field.
	Description string
	// Args is the list of arguments that the field accepts.
	Args InputSpecs
	// Type is the type of the field's result.
	Type Typed
	// Sensitive indicates that the value returned by this field is sensitive and
	// should not be displayed in telemetry.
	Sensitive bool
	// DeprecatedReason deprecates the field and provides a reason.
	DeprecatedReason *string
	// ExperimentalReason marks the field as experimental and provides a reason.
	ExperimentalReason string
	// Module is frame-native provenance for the module that provides the field's
	// implementation.
	Module *ResultCallModule
	// Directives is the list of GraphQL directives attached to this field.
	Directives []*ast.Directive
	// BuiltinLoadByIDFunc is the execution path for schema-generated
	// load<Type>FromID fields, which re-enter the graph from an object ID
	// rather than behaving like normal field resolvers.
	BuiltinLoadByIDFunc LoadByIDFunc

	// ViewFilter is filter that specifies under which views this field is
	// accessible. If not view is present, the default is the "global" view.
	ViewFilter ViewFilter

	// If set, the result of this field will never be cached and not have concurrent equal
	// calls deduped. The string value is a reason why the field should not be cached.
	DoNotCache string

	// If set, the result of this field will be cached for the given TTL (in seconds).
	TTL int64

	// If set, the result of this field is eligible for persistent cache storage.
	IsPersistable bool

	// If set, this GetDynamicInput will be called before cache evaluation to
	// make any dynamic adjustments to the call request or its policy.
	GetDynamicInput GenericDynamicInputFunc

	// ImplicitInputs are engine-computed inputs that are attached to the call
	// identity but are not explicit GraphQL field args.
	ImplicitInputs []ImplicitInput

	// NoTelemetry suppresses telemetry (AroundFunc) for this field.
	// Used for entrypoint proxies that delegate to real fields which
	// emit their own telemetry.
	NoTelemetry bool

	// Trivial marks fields that only unwrap data from their receiver rather
	// than performing meaningful work. Used to suppress install-span capture
	// for synthetic accessors (e.g. auto-generated module object field
	// accessors) so they don't claim ownership of values they merely return.
	Trivial bool
	// contains filtered or unexported fields
}

FieldSpec is a specification for a field.

func (FieldSpec) FieldDefinition

func (spec FieldSpec) FieldDefinition(view call.View) *ast.FieldDefinition

type Fields

type Fields[T Typed] []Field[T]

Fields defines a set of fields for an Object type.

func (Fields[T]) Install

func (fields Fields[T]) Install(server *Server)

Install installs the field's Object type if needed, and installs all fields into the type.

type Float

type Float float64

Float is a GraphQL Float scalar.

func NewFloat

func NewFloat[T constraints.Float](val T) Float

func (Float) DecodeInput

func (Float) DecodeInput(val any) (Input, error)

func (Float) Decoder

func (Float) Decoder() InputDecoder

func (Float) Float64

func (f Float) Float64() float64

func (Float) MarshalJSON

func (f Float) MarshalJSON() ([]byte, error)

func (Float) SetField

func (f Float) SetField(v reflect.Value) error

func (Float) ToLiteral

func (f Float) ToLiteral() call.Literal

func (Float) Type

func (Float) Type() *ast.Type

func (Float) TypeDefinition

func (f Float) TypeDefinition(view call.View) *ast.Definition

func (Float) TypeName

func (Float) TypeName() string

func (*Float) UnmarshalJSON

func (f *Float) UnmarshalJSON(p []byte) error

type ForkableObjectType added in v0.21.0

type ForkableObjectType interface {
	ForkObjectType(*Server) (ObjectType, error)
}

ForkableObjectType is an installed object type that can be safely cloned into another server without sharing mutable server-bound state like field tables or schema-cache invalidation callbacks.

type FuncHandler added in v0.16.3

type FuncHandler[T Typed, A any, R any] func(ctx context.Context, self T, args A) (R, error)

type GenericDynamicInputFunc added in v0.21.0

type GenericDynamicInputFunc func(
	context.Context,
	AnyResult,
	map[string]Input,
	call.View,
	*CallRequest,
) error

type HasDependencyResults added in v0.21.0

type HasDependencyResults interface {
	AttachDependencyResults(context.Context, AnyResult, func(AnyResult) (AnyResult, error)) ([]AnyResult, error)
}

HasDependencyResults is implemented by resolver-returned values that embed dependency results which must be normalized onto attached/cache-backed results before lifecycle bookkeeping or persistence.

Implementations must:

  • use self when they need to rewrite internal references to the attached owner result itself
  • call attach for each embedded child result that should be normalized
  • rewrite themselves in place to point at the attached result returned by attach
  • return only the subset of attached child results that should become explicit non-structural cache dependency edges

Returned deps are treated as owned: the install span of the parent (the API span that returned the parent value to a session) is attributed to each dep, so failures in the dep's lazy work mark the parent's install span as caused-failed. Implementations that want some deps to be liveness-only (no failure attribution) should implement HasDependencyResultsKinds instead.

type HasDependencyResultsKinds added in v0.21.0

type HasDependencyResultsKinds interface {
	AttachDependencyResultsKinds(context.Context, AnyResult, func(AnyResult) (AnyResult, error)) ([]DependencyResult, error)
}

HasDependencyResultsKinds is the kind-aware variant of HasDependencyResults. When a value implements both, this one is preferred — the result kind flag (Owned) controls install-span propagation for failure attribution.

type HasLazyEvaluation added in v0.21.0

type HasLazyEvaluation interface {
	LazyEvalFunc() LazyEvalFunc
}

type ID

type ID[T Typed] struct {
	// contains filtered or unexported fields
}

ID is a type-checked ID scalar.

func NewDynamicID

func NewDynamicID[T Typed](id *call.ID, typed T) ID[T]

func NewID

func NewID[T Typed](id *call.ID) ID[T]

func (*ID[T]) Decode

func (i *ID[T]) Decode(str string) error

func (ID[T]) DecodeInput

func (i ID[T]) DecodeInput(val any) (Input, error)

New creates a new ID with the given value.

It accepts either an *call.ID or a string. The string is expected to be the base64-encoded representation of an *call.ID.

func (ID[T]) Decoder

func (i ID[T]) Decoder() InputDecoder

func (ID[T]) Display

func (i ID[T]) Display() string

func (ID[T]) Encode

func (i ID[T]) Encode() (string, error)

func (ID[T]) ID

func (i ID[T]) ID() (*call.ID, error)

ID returns the ID of the value.

func (ID[T]) Load

func (i ID[T]) Load(ctx context.Context, server *Server) (res ObjectResult[T], _ error)

Load loads the instance with the given ID from the server.

func (ID[T]) MarshalJSON

func (i ID[T]) MarshalJSON() ([]byte, error)

func (ID[T]) SetField

func (i ID[T]) SetField(v reflect.Value) error

func (ID[T]) String

func (i ID[T]) String() string

String returns the ID in TypeName@<encoded-id> debug format.

func (ID[T]) ToLiteral

func (i ID[T]) ToLiteral() call.Literal

func (ID[T]) Type

func (i ID[T]) Type() *ast.Type

Type returns the GraphQL type of the value.

func (ID[T]) TypeDefinition

func (i ID[T]) TypeDefinition(view call.View) *ast.Definition

TypeDefinition returns the GraphQL definition of the type.

func (ID[T]) TypeName

func (i ID[T]) TypeName() string

TypeName returns the name of the type with "ID" appended, e.g. `FooID`.

func (*ID[T]) UnmarshalJSON

func (i *ID[T]) UnmarshalJSON(p []byte) error

type IDType

type IDType interface {
	Input
	IDable
	ScalarType
}

type IDable

type IDable interface {
	// ID returns the runtime handle ID of the value.
	ID() (*call.ID, error)
}

type ImplicitInput added in v0.21.0

type ImplicitInput struct {
	Name     string
	Resolver ImplicitInputResolver
}

func PerSchemaInput added in v0.21.0

func PerSchemaInput(srv *Server) ImplicitInput

PerSchemaInput scopes a call ID to the server schema digest.

func RequestedCacheInput added in v0.21.0

func RequestedCacheInput(argName string) ImplicitInput

RequestedCacheInput scopes a call ID according to a boolean argument: false => PerClientInput, true => PerCallInput.

type ImplicitInputResolver added in v0.21.0

type ImplicitInputResolver func(context.Context, map[string]Input) (Input, error)

type Input

type Input interface {
	// All Inputs are typed.
	Typed
	// All Inputs are able to be represented as a Literal.
	call.Literate
	// All Inputs now how to decode new instances of themselves.
	Decoder() InputDecoder
}

Input represents any value which may be passed as an input.

type InputDecoder

type InputDecoder interface {
	// Decode converts a value to the Input type, if possible.
	DecodeInput(any) (Input, error)
}

InputDecoder is a type that knows how to decode values into Inputs.

type InputObject

type InputObject[T Type] struct {
	Value T
	// contains filtered or unexported fields
}

func (InputObject[T]) Decoder

func (InputObject[T]) Decoder() InputDecoder

func (InputObject[T]) ToLiteral

func (input InputObject[T]) ToLiteral() call.Literal

func (InputObject[T]) Type

func (InputObject[T]) Type() *ast.Type

type InputObjectSpec

type InputObjectSpec struct {
	Name        string
	Description string
	Fields      InputSpecs
}

func MustInputSpec

func MustInputSpec(val Type) InputObjectSpec

func (InputObjectSpec) Install

func (spec InputObjectSpec) Install(srv *Server)

func (InputObjectSpec) Type

func (spec InputObjectSpec) Type() *ast.Type

func (InputObjectSpec) TypeDefinition

func (spec InputObjectSpec) TypeDefinition(view call.View) *ast.Definition

func (InputObjectSpec) TypeName

func (spec InputObjectSpec) TypeName() string

type InputSpec

type InputSpec struct {
	// Name is the name of the argument.
	Name string
	// Description is the description of the argument.
	Description string
	// Type is the type of the argument.
	Type Input
	// Default is the default value of the argument.
	Default Input
	// DeprecatedReason deprecates the input and provides a reason.
	DeprecatedReason *string
	// ExperimentalReason marks the field as experimental and provides a reason.
	ExperimentalReason string
	// Sensitive indicates that the value of this arg is sensitive and should be
	// omitted from telemetry.
	Sensitive bool
	// Directives is the list of GraphQL directives attached to this input.
	Directives []*ast.Directive

	// ViewFilter is filter that specifies under which views this field is
	// accessible. If not view is present, the default is the "global" view.
	ViewFilter ViewFilter

	// Internal indicates that this input can only be set by internal server
	// calls, never by external clients. It may appear in IDs sent to/from
	// clients, but can't be set in new graphql queries.
	// This argument will not be exposed in the introspection schema.
	Internal bool
}

InputSpec specifies a field argument, or an input field.

type InputSpecs

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

func InputSpecsForType added in v0.17.2

func InputSpecsForType(obj any, optIn bool) (InputSpecs, error)

func NewInputSpecs added in v0.18.6

func NewInputSpecs(specs ...InputSpec) InputSpecs

func (*InputSpecs) Add added in v0.18.6

func (specs *InputSpecs) Add(target ...InputSpec)

func (InputSpecs) ArgumentDefinitions

func (specs InputSpecs) ArgumentDefinitions(view call.View) []*ast.ArgumentDefinition

func (InputSpecs) Decode added in v0.17.2

func (specs InputSpecs) Decode(inputs map[string]Input, dest any, view call.View) error

func (InputSpecs) FieldDefinitions

func (specs InputSpecs) FieldDefinitions(view call.View) (defs []*ast.FieldDefinition)

func (InputSpecs) HasRequired added in v0.19.7

func (specs InputSpecs) HasRequired(view call.View) bool

func (InputSpecs) Input added in v0.18.6

func (specs InputSpecs) Input(name string, view call.View) (InputSpec, bool)

func (InputSpecs) Inputs added in v0.18.6

func (specs InputSpecs) Inputs(view call.View) (args []InputSpec)

func (InputSpecs) InputsFromResultCallArgs added in v0.21.0

func (specs InputSpecs) InputsFromResultCallArgs(ctx context.Context, args []*ResultCallArg, view call.View) (map[string]Input, error)

type Inputs

type Inputs []NamedInput

func (Inputs) Lookup

func (args Inputs) Lookup(name string) (Input, bool)

type InstallHook added in v0.17.0

type InstallHook interface {
	InstallObject(ObjectType, ...*ast.Directive)
}

type InstallHookForker added in v0.21.0

type InstallHookForker interface {
	ForkInstallHook(*Server) InstallHook
}

InstallHookForker is implemented by install hooks that carry server-specific state and must be rebound when a server is forked.

type Int

type Int int64

Int is a GraphQL Int scalar.

func NewInt

func NewInt[T constraints.Integer](val T) Int

func (Int) DecodeInput

func (Int) DecodeInput(val any) (Input, error)

func (Int) Decoder

func (Int) Decoder() InputDecoder

func (Int) Int

func (i Int) Int() int

func (Int) Int64

func (i Int) Int64() int64

func (Int) MarshalJSON

func (i Int) MarshalJSON() ([]byte, error)

func (Int) SetField

func (i Int) SetField(v reflect.Value) error

func (Int) ToLiteral

func (i Int) ToLiteral() call.Literal

func (Int) Type

func (Int) Type() *ast.Type

func (Int) TypeDefinition

func (i Int) TypeDefinition(view call.View) *ast.Definition

func (Int) TypeName

func (Int) TypeName() string

func (*Int) UnmarshalJSON

func (i *Int) UnmarshalJSON(p []byte) error

type InterfaceValue added in v0.18.13

type InterfaceValue interface {
	// UnderlyingObject returns the underlying object of the InterfaceValue
	UnderlyingObject() (Typed, error)
}

InterfaceValue is a value that wraps some underlying object with a interface to that object's API. This type exists to support unwrapping it and getting the underlying object.

type LazyEvalFunc added in v0.21.0

type LazyEvalFunc func(context.Context) error

type LoadByIDFunc added in v0.21.0

type LoadByIDFunc func(context.Context, AnyResult, map[string]Input) (AnyResult, error)

LoadByIDFunc is the builtin execution path for schema-generated load<Type>FromID fields.

type NamedInput

type NamedInput struct {
	Name  string
	Value Input
}

func (NamedInput) String

func (arg NamedInput) String() string

type NodeFuncHandler added in v0.16.3

type NodeFuncHandler[T Typed, A any, R any] func(ctx context.Context, self ObjectResult[T], args A) (R, error)

type Nullable

type Nullable[T Typed] struct {
	Value T
	Valid bool
}

Nullable wraps a type and allows it to be null.

This is used for optional arguments and return values.

func MapOpt

func MapOpt[I Input, R Typed](opt Optional[I], fn func(I) (R, error)) (Nullable[R], error)

func NonNull

func NonNull[T Typed](val T) Nullable[T]

func Null

func Null[T Typed]() Nullable[T]

func (Nullable[T]) Deref

func (n Nullable[T]) Deref() (Typed, bool)

func (Nullable[T]) DerefToResult added in v0.18.13

func (n Nullable[T]) DerefToResult(
	call *ResultCall,
) (AnyResult, bool)

func (Nullable[T]) MarshalJSON

func (n Nullable[T]) MarshalJSON() ([]byte, error)

func (Nullable[T]) Type

func (n Nullable[T]) Type() *ast.Type

func (*Nullable[T]) UnmarshalJSON

func (n *Nullable[T]) UnmarshalJSON(p []byte) error

type ObjectResult added in v0.18.13

type ObjectResult[T Typed] struct {
	Result[T]
	// contains filtered or unexported fields
}

func LoadIDResults added in v0.18.13

func LoadIDResults[T Typed](ctx context.Context, srv *Server, ids []ID[T]) ([]ObjectResult[T], error)

func NewObjectResultForCall added in v0.21.0

func NewObjectResultForCall[T Typed](
	self T,
	srv *Server,
	call *ResultCall,
) (res ObjectResult[T], _ error)

func NewObjectResultForCurrentCall added in v0.21.0

func NewObjectResultForCurrentCall[T Typed](
	ctx context.Context,
	srv *Server,
	self T,
) (ObjectResult[T], error)

func (ObjectResult[T]) DerefValue added in v0.18.13

func (r ObjectResult[T]) DerefValue() (AnyResult, bool)

func (ObjectResult[T]) MarshalJSON added in v0.18.13

func (r ObjectResult[T]) MarshalJSON() ([]byte, error)

func (ObjectResult[T]) NullableWrapped added in v0.21.0

func (r ObjectResult[T]) NullableWrapped() AnyResult

func (ObjectResult[T]) ObjectType added in v0.18.13

func (r ObjectResult[T]) ObjectType() ObjectType

ObjectType returns the ObjectType of the instance.

func (ObjectResult[T]) Receiver added in v0.21.0

func (r ObjectResult[T]) Receiver(ctx context.Context, srv *Server) (AnyObjectResult, error)

func (ObjectResult[T]) Select added in v0.18.13

func (r ObjectResult[T]) Select(ctx context.Context, s *Server, sel Selector) (AnyResult, error)

Select calls the field on the instance specified by the selector

func (ObjectResult[T]) SetField added in v0.18.13

func (r ObjectResult[T]) SetField(field reflect.Value) error

func (ObjectResult[T]) WithContentDigest added in v0.19.11

func (r ObjectResult[T]) WithContentDigest(ctx context.Context, contentDigest digest.Digest) (ObjectResult[T], error)

func (ObjectResult[T]) WithContentDigestAny added in v0.20.0

func (r ObjectResult[T]) WithContentDigestAny(ctx context.Context, customDigest digest.Digest) (AnyResult, error)

WithContentDigestAny is WithContentDigest but returns an AnyResult, required for polymorphic code paths like module function call plumbing.

func (ObjectResult[T]) WithSessionResourceHandle added in v0.21.0

func (r ObjectResult[T]) WithSessionResourceHandle(ctx context.Context, handle SessionResourceHandle) (ObjectResult[T], error)

func (ObjectResult[T]) WithSessionResourceHandleAny added in v0.21.0

func (r ObjectResult[T]) WithSessionResourceHandleAny(ctx context.Context, handle SessionResourceHandle) (AnyResult, error)

type ObjectResultArray added in v0.18.13

type ObjectResultArray[T Typed] []ObjectResult[T]

func (ObjectResultArray[T]) AttachDependencyResults added in v0.21.0

func (arr ObjectResultArray[T]) AttachDependencyResults(
	_ context.Context,
	_ AnyResult,
	attach func(AnyResult) (AnyResult, error),
) ([]AnyResult, error)

func (ObjectResultArray[T]) Element added in v0.18.13

func (arr ObjectResultArray[T]) Element() Typed

func (ObjectResultArray[T]) Len added in v0.18.13

func (arr ObjectResultArray[T]) Len() int

func (ObjectResultArray[T]) Nth added in v0.18.13

func (arr ObjectResultArray[T]) Nth(i int) (Typed, error)

func (ObjectResultArray[T]) NthValue added in v0.18.13

func (arr ObjectResultArray[T]) NthValue(i int, _ *ResultCall) (AnyResult, error)

func (ObjectResultArray[T]) Type added in v0.18.13

func (i ObjectResultArray[T]) Type() *ast.Type

type ObjectType

type ObjectType interface {
	Type
	// Typed returns a Typed value whose Type refers to the object type.
	Typed() Typed
	// IDType returns the scalar type for the object's IDs.
	IDType() (IDType, bool)
	// New creates a new instance of the type.
	New(val AnyResult) (AnyObjectResult, error)
	// ParseField parses the given field and returns a Selector and an expected
	// return type.
	ParseField(ctx context.Context, view call.View, astField *ast.Field, vars map[string]any) (Selector, *ast.Type, error)
	// Extend registers an additional field onto the type.
	//
	// Unlike natively added fields, the extended func is limited to the external
	// Object interface.
	// cacheConfigFunc is optional, if not set the default dagql ID cache key will be used.
	Extend(spec FieldSpec, fun FieldFunc)
	// ExtendLoadByID registers a builtin load<Type>FromID field that re-enters
	// the graph from an object ID instead of behaving like a normal field
	// resolver.
	ExtendLoadByID(spec FieldSpec, fun LoadByIDFunc)
	// FieldSpec looks up a field spec by name.
	FieldSpec(name string, view call.View) (FieldSpec, bool)
	// FieldSpecs returns all field specs visible under the given view.
	FieldSpecs(view call.View) []FieldSpec
}

ObjectType represents a GraphQL Object type.

type OnReleaseFunc added in v0.20.0

type OnReleaseFunc = func(context.Context) error

type OnReleaser added in v0.16.3

type OnReleaser interface {
	OnRelease(context.Context) error
}

A type that has a callback attached that needs to always run when the result is removed from the cache

type OperationLeaseProvider added in v0.21.0

type OperationLeaseProvider interface {
	WithOperationLease(context.Context) (context.Context, func(context.Context) error, error)
}

type OperationLeaseProviderFunc added in v0.21.0

type OperationLeaseProviderFunc func(context.Context) (context.Context, func(context.Context) error, error)

func (OperationLeaseProviderFunc) WithOperationLease added in v0.21.0

func (f OperationLeaseProviderFunc) WithOperationLease(ctx context.Context) (context.Context, func(context.Context) error, error)

type Optional

type Optional[I Input] struct {
	Value I
	// true if the value is set
	Valid bool
}

Optional wraps a type and allows it to be null.

This is used for optional arguments and return values.

func NoOpt

func NoOpt[I Input]() Optional[I]

NoOpt returns an empty Optional value.

func Opt

func Opt[I Input](v I) Optional[I]

func (Optional[I]) AsPtr added in v0.18.18

func (n Optional[I]) AsPtr() *I

func (Optional[I]) DecodeInput

func (o Optional[I]) DecodeInput(val any) (Input, error)

func (Optional[I]) Decoder

func (o Optional[I]) Decoder() InputDecoder

func (Optional[I]) Deref

func (o Optional[I]) Deref() (Typed, bool)

func (Optional[I]) GetOr

func (n Optional[I]) GetOr(v I) I

GetOr returns the value of the Optional, or the given value if the Optional is empty.

func (Optional[I]) MarshalJSON

func (o Optional[I]) MarshalJSON() ([]byte, error)

func (Optional[I]) SetField added in v0.18.18

func (o Optional[I]) SetField(val reflect.Value) error

func (Optional[I]) ToLiteral

func (o Optional[I]) ToLiteral() call.Literal

func (Optional[I]) ToNullable

func (o Optional[I]) ToNullable() Nullable[I]

func (Optional[I]) Type

func (o Optional[I]) Type() *ast.Type

func (*Optional[I]) UnmarshalJSON

func (o *Optional[I]) UnmarshalJSON(p []byte) error

type PanicError added in v0.10.0

type PanicError struct {
	Cause     any
	Self      AnyResult
	Selection Selection
	Stack     []byte
}

func (PanicError) Error added in v0.10.0

func (err PanicError) Error() string

type PersistedObject added in v0.21.0

type PersistedObject interface {
	Typed
	EncodePersistedObject(context.Context, PersistedObjectCache) (PersistedObjectEncoding, error)
}

PersistedObject is implemented by object self payloads that can be encoded directly for import-time cache persistence.

type PersistedObjectCache added in v0.21.0

type PersistedObjectCache interface {
	PersistedResultID(AnyResult) (uint64, error)
}

type PersistedObjectDecoder added in v0.21.0

type PersistedObjectDecoder interface {
	Typed
	DecodePersistedObject(context.Context, *Server, uint64, *ResultCall, json.RawMessage) (Typed, error)
}

PersistedObjectDecoder is implemented by zero-value object types that know how to reconstruct a persisted object self payload without replaying the original dagql call chain.

type PersistedObjectEncoding added in v0.21.0

type PersistedObjectEncoding struct {
	JSON          json.RawMessage
	SnapshotLinks []PersistedSnapshotRefLink
}

type PersistedResultEncoding added in v0.21.0

type PersistedResultEncoding struct {
	Envelope      PersistedResultEnvelope
	SnapshotLinks []PersistedSnapshotRefLink
}

type PersistedResultEnvelope added in v0.21.0

type PersistedResultEnvelope struct {
	Version               int                       `json:"version"`
	Kind                  string                    `json:"kind"`
	TypeName              string                    `json:"typeName,omitempty"`
	ResultID              uint64                    `json:"resultID,omitempty"`
	SessionResourceHandle SessionResourceHandle     `json:"sessionResourceHandle,omitempty"`
	ObjectJSON            json.RawMessage           `json:"objectJSON,omitempty"`
	ScalarJSON            json.RawMessage           `json:"scalarJSON,omitempty"`
	ElemTypeName          string                    `json:"elemTypeName,omitempty"`
	Items                 []PersistedResultEnvelope `json:"items,omitempty"`
}

PersistedResultEnvelope is the shared on-disk payload envelope for persisted result self values.

This is intentionally opaque at the DB level (stored as self_payload bytes), while still carrying enough structured data to decode common SDK-return shapes (scalars, object IDs, lists, nested combinations).

type PersistedSelfCodec added in v0.21.0

PersistedSelfCodec is the shared interface used to encode/decode result self payloads for disk persistence.

var DefaultPersistedSelfCodec PersistedSelfCodec = defaultPersistedSelfCodec{}
type PersistedSnapshotRefLink struct {
	RefKey string
	Role   string
}

PersistedSnapshotRefLink is a generic non-opaque link from a persisted result self payload to one durable snapshot ref key.

type PersistedSnapshotRefLinkProvider added in v0.21.0

type PersistedSnapshotRefLinkProvider interface {
	PersistedSnapshotRefLinks() []PersistedSnapshotRefLink
}

PersistedSnapshotRefLinkProvider is the shared interface used by persistable self payloads to expose snapshot ref links for `result_snapshot_links`.

type RecipeIDable added in v0.21.0

type RecipeIDable interface {
	// RecipeID returns the semantic recipe ID of the value.
	RecipeID(context.Context) (*call.ID, error)
}

type Result added in v0.18.13

type Result[T Typed] struct {
	// contains filtered or unexported fields
}

func NewResultForCall added in v0.21.0

func NewResultForCall[T Typed](
	self T,
	call *ResultCall,
) (res Result[T], _ error)

NewResultForCall creates a new Result with the given call and self value.

func NewResultForCurrentCall added in v0.21.0

func NewResultForCurrentCall[T Typed](
	ctx context.Context,
	self T,
) (Result[T], error)

NewResultForCurrentCall creates a new Result that's set to the current call from the given self value.

func (Result[T]) ContentPreferredDigest added in v0.21.0

func (r Result[T]) ContentPreferredDigest(ctx context.Context) (digest.Digest, error)

func (Result[T]) DerefValue added in v0.18.13

func (r Result[T]) DerefValue() (AnyResult, bool)

func (Result[T]) HitCache added in v0.20.0

func (r Result[T]) HitCache() bool

func (Result[T]) ID added in v0.18.13

func (r Result[T]) ID() (*call.ID, error)

ID returns the runtime handle ID of the instance.

func (Result[T]) MarshalJSON added in v0.18.13

func (r Result[T]) MarshalJSON() ([]byte, error)

func (Result[T]) NthValue added in v0.18.13

func (r Result[T]) NthValue(ctx context.Context, nth int) (AnyResult, error)

func (Result[T]) NullableWrapped added in v0.21.0

func (r Result[T]) NullableWrapped() AnyResult

func (Result[T]) RecipeDigest added in v0.21.0

func (r Result[T]) RecipeDigest(ctx context.Context) (digest.Digest, error)

func (Result[T]) RecipeID added in v0.21.0

func (r Result[T]) RecipeID(ctx context.Context) (*call.ID, error)

func (Result[T]) ResultCall added in v0.21.0

func (r Result[T]) ResultCall() (*ResultCall, error)

func (Result[T]) Self added in v0.18.13

func (r Result[T]) Self() T

func (Result[T]) SetField added in v0.18.13

func (r Result[T]) SetField(field reflect.Value) error

func (Result[T]) String added in v0.18.13

func (r Result[T]) String() string

String returns the instance in Class@sha256:... format.

func (Result[T]) Type added in v0.18.13

func (r Result[T]) Type() *ast.Type

func (Result[T]) Unwrap added in v0.18.13

func (r Result[T]) Unwrap() Typed

Unwrap returns the inner value of the instance.

func (Result[T]) WithContentDigest added in v0.19.11

func (r Result[T]) WithContentDigest(ctx context.Context, contentDigest digest.Digest) (Result[T], error)

func (Result[T]) WithContentDigestAny added in v0.20.0

func (r Result[T]) WithContentDigestAny(ctx context.Context, customDigest digest.Digest) (AnyResult, error)

WithContentDigestAny is WithContentDigest but returns an AnyResult, required for polymorphic code paths like module function call plumbing.

func (Result[T]) WithSessionResourceHandle added in v0.21.0

func (r Result[T]) WithSessionResourceHandle(ctx context.Context, handle SessionResourceHandle) (Result[T], error)

func (Result[T]) WithSessionResourceHandleAny added in v0.21.0

func (r Result[T]) WithSessionResourceHandleAny(ctx context.Context, handle SessionResourceHandle) (AnyResult, error)

type ResultArray added in v0.18.13

type ResultArray[T Typed] []Result[T]

func (ResultArray[T]) Element added in v0.18.13

func (arr ResultArray[T]) Element() Typed

func (ResultArray[T]) Len added in v0.18.13

func (arr ResultArray[T]) Len() int

func (ResultArray[T]) Nth added in v0.18.13

func (arr ResultArray[T]) Nth(i int) (Typed, error)

func (ResultArray[T]) NthValue added in v0.18.13

func (arr ResultArray[T]) NthValue(i int, _ *ResultCall) (AnyResult, error)

func (ResultArray[T]) Type added in v0.18.13

func (i ResultArray[T]) Type() *ast.Type

type ResultCall added in v0.21.0

type ResultCall struct {
	Kind        ResultCallKind  `json:"kind"`
	Type        *ResultCallType `json:"type,omitempty"`
	Field       string          `json:"field,omitempty"`
	SyntheticOp string          `json:"syntheticOp,omitempty"`
	View        call.View       `json:"view,omitempty"`
	Nth         int64           `json:"nth,omitempty"`
	EffectIDs   []string        `json:"effectIDs,omitempty"`
	// ExtraDigests are the original extra digests explicitly attached when this
	// call/result was first created. They are useful provenance, but they are
	// not the authoritative merged digest state. The cache/e-graph remains the
	// source of truth for the full merged output-equivalence digest set.
	ExtraDigests   []call.ExtraDigest `json:"extraDigests,omitempty"`
	Receiver       *ResultCallRef     `json:"receiver,omitempty"`
	Module         *ResultCallModule  `json:"module,omitempty"`
	Args           []*ResultCallArg   `json:"args,omitempty"`
	ImplicitInputs []*ResultCallArg   `json:"implicitInputs,omitempty"`
	// contains filtered or unexported fields
}

func ChildFieldCall added in v0.21.0

func ChildFieldCall(parent *ResultCall, field string, fieldType *ast.Type) *ResultCall

ChildFieldCall derives the call frame for a child field selection while preserving the receiver lineage, module, and view from the parent call.

func CurrentCall added in v0.21.0

func CurrentCall(ctx context.Context) *ResultCall

func (*ResultCall) AllEffectIDs added in v0.21.0

func (frame *ResultCall) AllEffectIDs() ([]string, error)

func (*ResultCall) CallPB added in v0.21.0

func (frame *ResultCall) CallPB(ctx context.Context) (*callpbv1.Call, error)

func (*ResultCall) ContentDigest added in v0.21.0

func (frame *ResultCall) ContentDigest() digest.Digest

func (*ResultCall) ContentPreferredDigest added in v0.21.0

func (frame *ResultCall) ContentPreferredDigest(ctx context.Context) (digest.Digest, error)

func (*ResultCall) Inputs added in v0.21.0

func (frame *ResultCall) Inputs(ctx context.Context) ([]digest.Digest, error)

func (*ResultCall) ReceiverCall added in v0.21.0

func (frame *ResultCall) ReceiverCall(ctx context.Context) (*ResultCall, error)

func (*ResultCall) RecipeDigest added in v0.21.0

func (frame *ResultCall) RecipeDigest(ctx context.Context) (digest.Digest, error)

func (*ResultCall) RecipeID added in v0.21.0

func (frame *ResultCall) RecipeID(ctx context.Context) (*call.ID, error)

func (*ResultCall) SelfDigestAndInputRefs added in v0.21.0

func (frame *ResultCall) SelfDigestAndInputRefs(ctx context.Context) (digest.Digest, []ResultCallStructuralInputRef, error)

type ResultCallArg added in v0.21.0

type ResultCallArg struct {
	Name        string             `json:"name,omitempty"`
	IsSensitive bool               `json:"isSensitive,omitempty"`
	Value       *ResultCallLiteral `json:"value,omitempty"`
}

type ResultCallKind added in v0.21.0

type ResultCallKind string
const (
	ResultCallKindField     ResultCallKind = "field"
	ResultCallKindSynthetic ResultCallKind = "synthetic"
)

type ResultCallLiteral added in v0.21.0

type ResultCallLiteral struct {
	Kind ResultCallLiteralKind `json:"kind"`

	BoolValue   bool    `json:"boolValue,omitempty"`
	IntValue    int64   `json:"intValue,omitempty"`
	FloatValue  float64 `json:"floatValue,omitempty"`
	StringValue string  `json:"stringValue,omitempty"`
	EnumValue   string  `json:"enumValue,omitempty"`

	DigestedStringValue  string        `json:"digestedStringValue,omitempty"`
	DigestedStringDigest digest.Digest `json:"digestedStringDigest,omitempty"`

	ResultRef    *ResultCallRef       `json:"resultRef,omitempty"`
	ListItems    []*ResultCallLiteral `json:"listItems,omitempty"`
	ObjectFields []*ResultCallArg     `json:"objectFields,omitempty"`
}

type ResultCallLiteralKind added in v0.21.0

type ResultCallLiteralKind string
const (
	ResultCallLiteralKindNull           ResultCallLiteralKind = "null"
	ResultCallLiteralKindBool           ResultCallLiteralKind = "bool"
	ResultCallLiteralKindInt            ResultCallLiteralKind = "int"
	ResultCallLiteralKindFloat          ResultCallLiteralKind = "float"
	ResultCallLiteralKindString         ResultCallLiteralKind = "string"
	ResultCallLiteralKindEnum           ResultCallLiteralKind = "enum"
	ResultCallLiteralKindDigestedString ResultCallLiteralKind = "digested_string"
	ResultCallLiteralKindResultRef      ResultCallLiteralKind = "result_ref"
	ResultCallLiteralKindList           ResultCallLiteralKind = "list"
	ResultCallLiteralKindObject         ResultCallLiteralKind = "object"
)

type ResultCallModule added in v0.21.0

type ResultCallModule struct {
	ResultRef *ResultCallRef `json:"resultRef,omitempty"`
	Name      string         `json:"name,omitempty"`
	Ref       string         `json:"ref,omitempty"`
	Pin       string         `json:"pin,omitempty"`
}

type ResultCallRef added in v0.21.0

type ResultCallRef struct {
	ResultID uint64      `json:"resultID,omitempty"`
	Call     *ResultCall `json:"call,omitempty"`
	// contains filtered or unexported fields
}

func (*ResultCallRef) Validate added in v0.21.0

func (ref *ResultCallRef) Validate() error

type ResultCallStructuralInputRef added in v0.21.0

type ResultCallStructuralInputRef struct {
	Result *ResultCallRef
	Digest digest.Digest
}

func (ResultCallStructuralInputRef) InputDigest added in v0.21.0

func (ResultCallStructuralInputRef) Validate added in v0.21.0

func (ref ResultCallStructuralInputRef) Validate() error

type ResultCallType added in v0.21.0

type ResultCallType struct {
	NamedType string          `json:"namedType,omitempty"`
	NonNull   bool            `json:"nonNull,omitempty"`
	Elem      *ResultCallType `json:"elem,omitempty"`
}

func NewResultCallType added in v0.21.0

func NewResultCallType(gqlType *ast.Type) *ResultCallType

type Scalar added in v0.11.3

type Scalar[T ScalarValue] struct {
	Name  string
	Value T
}

Scalar is a GraphQL scalar.

func NewScalar added in v0.11.3

func NewScalar[T ScalarValue](name string, val T) Scalar[T]

func (Scalar[T]) DecodeInput added in v0.11.3

func (s Scalar[T]) DecodeInput(val any) (Input, error)

func (Scalar[T]) Decoder added in v0.11.3

func (s Scalar[T]) Decoder() InputDecoder

func (Scalar[T]) MarshalJSON added in v0.11.3

func (s Scalar[T]) MarshalJSON() ([]byte, error)

func (Scalar[T]) ToLiteral added in v0.11.3

func (s Scalar[T]) ToLiteral() call.Literal

func (Scalar[T]) Type added in v0.11.3

func (s Scalar[T]) Type() *ast.Type

func (Scalar[T]) TypeDefinition added in v0.11.3

func (s Scalar[T]) TypeDefinition(view call.View) *ast.Definition

func (Scalar[T]) TypeName added in v0.11.3

func (s Scalar[T]) TypeName() string

func (*Scalar[T]) UnmarshalJSON added in v0.11.3

func (s *Scalar[T]) UnmarshalJSON(p []byte) error

type ScalarType

type ScalarType interface {
	Type
	InputDecoder
}

ScalarType represents a GraphQL Scalar type.

type ScalarValue added in v0.11.3

type ScalarValue interface {
	ScalarType
	Input
}

type Selection

type Selection struct {
	Alias         string
	Selector      Selector
	Subselections []Selection
}

Selection represents a selection of a field on an object.

func (Selection) Name

func (sel Selection) Name() string

Name returns the name of the selection, which is either the alias or the field name.

type Selector

type Selector struct {
	Field string
	Args  []NamedInput
	Nth   int
	View  call.View
}

Selector specifies how to retrieve a value from an Result.

func (Selector) String

func (sel Selector) String() string

type SerializedString added in v0.18.13

type SerializedString[T any] struct {
	Self T
}

func NewSerializedString added in v0.18.13

func NewSerializedString[T any](val T) SerializedString[T]

func (SerializedString[T]) DecodeInput added in v0.18.13

func (SerializedString[T]) DecodeInput(val any) (Input, error)

func (SerializedString[T]) Decoder added in v0.18.13

func (s SerializedString[T]) Decoder() InputDecoder

func (SerializedString[T]) MarshalJSON added in v0.18.13

func (s SerializedString[T]) MarshalJSON() ([]byte, error)

func (SerializedString[T]) SetField added in v0.18.13

func (s SerializedString[T]) SetField(v reflect.Value) error

func (SerializedString[T]) String added in v0.18.13

func (s SerializedString[T]) String() string

func (SerializedString[T]) ToLiteral added in v0.18.13

func (s SerializedString[T]) ToLiteral() call.Literal

func (SerializedString[T]) Type added in v0.18.13

func (SerializedString[T]) Type() *ast.Type

func (*SerializedString[T]) UnmarshalJSON added in v0.18.13

func (s *SerializedString[T]) UnmarshalJSON(p []byte) error

type Server

type Server struct {

	// View is the default view that is applied to queries on this server.
	//
	// WARNING: this is *not* the view of the current query (for that, inspect
	// the current id)
	View call.View
	// contains filtered or unexported fields
}

Server represents a GraphQL server whose schema is dynamically modified at runtime.

func CurrentDagqlServer added in v0.18.4

func CurrentDagqlServer(ctx context.Context) *Server

func NewServer

func NewServer[T Typed](_ context.Context, root T) (*Server, error)

NewServer returns a new Server with the given root object.

func (*Server) AddInstallHook added in v0.17.0

func (s *Server) AddInstallHook(hook InstallHook)

Attach an install hook

func (*Server) Around

func (s *Server) Around(rec AroundFunc)

Around installs a function to be called around every non-cached selection.

func (*Server) Canonical added in v0.20.4

func (s *Server) Canonical() *Server

func (*Server) Complexity

func (s *Server) Complexity(ctx context.Context, typeName, field string, childComplexity int, args map[string]any) (int, bool)

Complexity returns the complexity of the given field.

func (*Server) Exec

Exec implements graphql.ExecutableSchema.

func (*Server) ExecOp

func (s *Server) ExecOp(ctx context.Context, gqlOp *graphql.OperationContext) (results map[string]any, rerr error)

func (*Server) Fork added in v0.21.0

func (s *Server) Fork(_ context.Context, root Typed) (*Server, error)

Fork returns a new server that starts with a clone of the current server's installed schema state but with an independent root object and independently mutable object type tables.

func (*Server) InstallDirective

func (s *Server) InstallDirective(directive DirectiveSpec)

InstallDirective installs the given Directive type into the schema.

func (*Server) InstallObject

func (s *Server) InstallObject(class ObjectType, directives ...*ast.Directive) ObjectType

InstallObject installs the given Object type into the schema, or returns the previously installed type if it was already present

func (*Server) InstallScalar

func (s *Server) InstallScalar(scalar ScalarType) ScalarType

InstallScalar installs the given Scalar type into the schema, or returns the previously installed type if it was already present

func (*Server) InstallTypeDef

func (s *Server) InstallTypeDef(def TypeDef)

InstallTypeDef installs an arbitrary type definition into the schema.

func (*Server) Load

func (s *Server) Load(ctx context.Context, id *call.ID) (AnyObjectResult, error)

Load loads the object with the given ID.

func (*Server) LoadType added in v0.16.3

func (s *Server) LoadType(ctx context.Context, id *call.ID) (_ AnyResult, rerr error)

func (*Server) ObjectType

func (s *Server) ObjectType(name string) (ObjectType, bool)

ObjectType returns the ObjectType with the given name, if it exists.

func (*Server) Query

func (s *Server) Query(ctx context.Context, query string, vars map[string]any) (map[string]any, error)

Query is a convenience method for executing a query against the server without having to go through HTTP. This can be useful for introspection, for example.

func (*Server) Resolve

func (s *Server) Resolve(ctx context.Context, self AnyObjectResult, sels ...Selection) (map[string]any, error)

Resolve resolves the given selections on the given object.

Each selection is resolved in parallel, and the results are returned in a map whose keys correspond to the selection's field name or alias.

func (*Server) Root

func (s *Server) Root() AnyObjectResult

Root returns the root object of the server. It is suitable for passing to Resolve to resolve a query.

func (*Server) ScalarType

func (s *Server) ScalarType(name string) (ScalarType, bool)

ScalarType returns the ScalarType with the given name, if it exists.

func (*Server) Schema

func (s *Server) Schema() *ast.Schema

Schema returns the current schema of the server.

func (*Server) SchemaDigest added in v0.18.11

func (s *Server) SchemaDigest() digest.Digest

SchemaDigest returns the digest of the current schema.

func (*Server) SchemaForView added in v0.19.11

func (s *Server) SchemaForView(view call.View) *ast.Schema

func (*Server) Select

func (s *Server) Select(ctx context.Context, self AnyObjectResult, dest any, sels ...Selector) (rerr error)

Select evaluates a series of chained field selections starting from the given object and assigns the final result value into dest.

func (*Server) SetCanonical added in v0.20.4

func (s *Server) SetCanonical(canonical *Server)

func (*Server) TypeDef

func (s *Server) TypeDef(name string) (TypeDef, bool)

InputType returns the InputType with the given name, if it exists.

type SessionResourceCandidate added in v0.21.0

type SessionResourceCandidate struct {
	ClientID string
	Value    any
}

type SessionResourceHandle added in v0.21.0

type SessionResourceHandle string

type Setter

type Setter interface {
	SetField(reflect.Value) error
}

Setter allows a type to populate fields of a struct.

This is how builtins are supported.

type String

type String string

String is a GraphQL String scalar.

func NewString

func NewString(val string) String

func (String) DecodeInput

func (String) DecodeInput(val any) (Input, error)

func (String) Decoder

func (String) Decoder() InputDecoder

func (String) MarshalJSON

func (s String) MarshalJSON() ([]byte, error)

func (String) SetField

func (s String) SetField(v reflect.Value) error

func (String) String

func (s String) String() string

func (String) ToLiteral

func (s String) ToLiteral() call.Literal

func (String) Type

func (String) Type() *ast.Type

func (String) TypeDefinition

func (s String) TypeDefinition(view call.View) *ast.Definition

func (String) TypeName

func (String) TypeName() string

func (*String) UnmarshalJSON

func (s *String) UnmarshalJSON(p []byte) error

type TelemetrySeenKeyStore added in v0.21.0

type TelemetrySeenKeyStore interface {
	LoadOrStoreTelemetrySeenKey(string) bool
	StoreTelemetrySeenKey(string)
}

type Type

type Type interface {
	// TypeName returns the name of the type.
	TypeName() string
}

Type is an object that defines a new GraphQL type.

type TypeDef

type TypeDef interface {
	Type
	Definitive
}

TypeDef is a type whose sole practical purpose is to define a GraphQL type, so it explicitly includes the Definitive interface.

type TypeResolver added in v0.21.0

type TypeResolver interface {
	ObjectType(name string) (ObjectType, bool)
	ScalarType(name string) (ScalarType, bool)
}

TypeResolver is the minimal schema lookup surface needed by dagql cache and persisted-payload reconstruction.

type Typed

type Typed interface {
	// Type returns the GraphQL type of the value.
	Type() *ast.Type
}

Typed is any value that knows its GraphQL type.

type ViewFilter added in v0.18.6

type ViewFilter interface {
	Contains(call.View) bool
}
var GlobalView ViewFilter = nil

GlobalView is the default global view. Everyone can see it, and it behaves identically everywhere.

type Wrapper

type Wrapper interface {
	Unwrap() Typed
}

Wrapper is an interface for types that wrap another type.

Directories

Path Synopsis
Package idtui provides terminal user interface frontends for Dagger operations.
Package idtui provides terminal user interface frontends for Dagger operations.
internal
ioctx
Package ioctx provides a way to pass standard input, output, and error streams through a context.Context.
Package ioctx provides a way to pass standard input, output, and error streams through a context.Context.

Jump to

Keyboard shortcuts

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