TrackedDataLoader #

Recommended form: no watch, load() receives the context.

Fields #

load(context: DataLoaderContext): MaybePromise<T>

Produces the data. Read files through context, so changes to them refresh the data.

read(path: string): Promise<string>

Reads a UTF-8 text file and records it as a dependency of this loader. A relative path starts from the loader file.

glob(pattern: string | readonly string[]): Promise<string[]>

Finds files and returns their absolute paths, sorted. The pattern is recorded as a dependency of this loader, so files that appear or go also refresh it. A relative pattern starts from the loader file.

optionsoptionalDataLoaderOptions

Extra options of the loader.

Full type signature
TypeScript
interface TrackedDataLoader<T = unknown> {
  watch?: undefined
  load: (context: DataLoaderContext) => MaybePromise<T>
  options?: DataLoaderOptions
}

Edit this page

Comments