GraphQLDependency class
One GraphQL object type's place in the dependency graph — its bulk loader, its optional initializer, and the child types it owns.
Signature:
export declare class GraphQLDependency<ResultType>
Remarks
Descriptions are registered one per GraphQLObjectType and are never constructed directly: the constructor is protected, and Dependency (or GraphQLDependency.create(), which it aliases) hands back the single description belonging to a type, creating it on first use. Two calls for the same type always return the same object, which is what lets the loader, the initializer and the requirements each be declared wherever is most natural — usually beside the type definition — and still add up to one description.
Three declarations build it up, all of them start-up work, and each returns this so they chain:
- GraphQLDependency.defineLoader() — how to fetch this type in bulk; - GraphQLDependency.require() — the child types this one owns; - GraphQLDependency.defineInitializer() — optional pre-fill for fields the dependency filters need but the initial result does not carry.
GraphQLDependency.load() is the runtime half, called once per request from a top-level resolver.
Resolution cascades rather than running per field. load() walks the requested field map, merges every request for the same type into a single field set, and calls the bulk loaders level by level — concurrently within a level — asking each for only the objects the request has not already fetched. Results are attached to the parents by id and by reference rather than copied, so a query reaching the same type from several directions costs one round trip per distinct filter instead of one per object.
Constructors
|
Constructor |
Modifiers |
Description |
|---|---|---|
|
|
Registers a description against its type. Not called directly — the constructor is |
Properties
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
|
GraphQLObjectType |
The GraphQL object type this description belongs to. Readable because both the registry and the per-request resolution cache are keyed by the type object itself, so anything walking the graph needs it. |
Methods
|
Method |
Modifiers |
Description |
|---|---|---|
|
|
Returns the dependency description for a GraphQL object type, creating and registering it the first time the type is seen. | |
|
Declares an async routine that fills extra fields onto this type's own objects before its dependencies are loaded. | ||
|
Declares how to fetch many objects of this type in one call, which is what makes the type usable as another type's dependency. | ||
|
|
Reports whether a filter assembled for a loader has nothing left to look up, so the loader can be skipped. | |
|
Loads everything the request asked for beneath this type and attaches it to the result, in as few bulk calls as the graph allows. | ||
|
Declares that this type owns a child type, and how the child's objects are found and where they are attached. |
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.