Documentation
¶
Index ¶
- func GetPatch(ctx context.Context, patchID string) (*patch.Patch, error)
- func GetProject(ctx context.Context, idOrIdentifier string) (*model.ProjectRef, error)
- func GetTask(ctx context.Context, taskID string) (*task.Task, error)
- func GetUser(ctx context.Context, userID string) (*user.DBUser, error)
- func GetVersion(ctx context.Context, versionID string) (*model.Version, error)
- func Inject(ctx context.Context) context.Context
- func IsBatchError(err error) bool
- func Middleware(next http.Handler) http.Handler
- func PreloadPatches(ctx context.Context, patchIDs []string)
- func PreloadProjects(ctx context.Context, idsOrIdentifiers []string)
- func PreloadTasks(ctx context.Context, taskIDs []string)
- func PreloadVersions(ctx context.Context, versionIDs []string)
- type Loaders
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPatch ¶
GetPatch returns a single patch by ID efficiently using the dataloader. Returns nil if the patch is not found.
func GetProject ¶
GetProject returns a single merged project ref by its id or identifier efficiently using the dataloader. Returns nil if the project is not found.
func GetTask ¶
GetTask returns a single task by ID efficiently using the dataloader. Returns nil if the task is not found.
func GetUser ¶
GetUser returns a single user by ID efficiently using the dataloader. Returns nil if the user is not found (e.g. service users).
func GetVersion ¶
GetVersion returns a single version by ID efficiently using the dataloader. Returns nil if the version is not found.
func Inject ¶
Inject returns a copy of ctx with a fresh set of data loaders attached. It is useful for tests that exercise resolver helpers directly without going through Middleware.
func IsBatchError ¶
IsBatchError reports whether err was produced by a dataloader batch operation and has already been logged. The GraphQL error presenter should skip logging these to avoid duplicate log entries.
func Middleware ¶
Middleware injects data loaders into the request context.
func PreloadPatches ¶
PreloadPatches enqueues every patch ID into the dataloader's current batch in a single synchronous loop, guaranteeing that subsequent GetPatch calls for these IDs are served from the loader's thunk cache without any additional MongoDB queries. Use this when a resolver knows up front that it will need many patches whose loads would otherwise be split across multiple batches due to the wait-time window.
Errors are intentionally discarded here; per-key errors are still surfaced to the individual GetPatch callers via the cached thunks.
func PreloadProjects ¶
PreloadProjects enqueues every project id or identifier into the dataloader's current batch in a single synchronous loop, guaranteeing that subsequent GetProject calls for these values are served from the loader's thunk cache without any additional MongoDB queries. Use this when a resolver knows up front that it will need many projects whose loads would otherwise be split across multiple batches due to the wait-time window.
Errors are intentionally discarded here; per-key errors are still surfaced to the individual GetProject callers via the cached thunks.
func PreloadTasks ¶
PreloadTasks enqueues every task ID into the dataloader's current batch in a single synchronous loop, guaranteeing that subsequent GetTask calls for these IDs are served from the loader's thunk cache without any additional MongoDB queries. Use this when a resolver knows up front that it will need many tasks whose loads would otherwise be split across multiple batches due to the wait-time window.
Errors are intentionally discarded here; per-key errors are still surfaced to the individual GetTask callers via the cached thunks.
func PreloadVersions ¶
PreloadVersions enqueues every version ID into the dataloader's current batch in a single synchronous loop, guaranteeing that subsequent GetVersion calls for these IDs are served from the loader's thunk cache without any additional MongoDB queries. Use this when a resolver knows up front that it will need many versions whose loads would otherwise be split across multiple batches due to the wait-time window (e.g. the TaskHistory resolver, where hundreds of inactive tasks each request their own version).
Errors are intentionally discarded here; per-key errors are still surfaced to the individual GetVersion callers via the cached thunks.
Types ¶
type Loaders ¶
type Loaders struct {
UserLoader *dataloadgen.Loader[string, *user.DBUser]
VersionLoader *dataloadgen.Loader[string, *model.Version]
ProjectLoader *dataloadgen.Loader[string, *model.ProjectRef]
TaskLoader *dataloadgen.Loader[string, *task.Task]
PatchLoader *dataloadgen.Loader[string, *patch.Patch]
}
Loaders contains all dataloader instances for batching GraphQL queries.