# GraphQLDependency class · @imqueue/graphql-dependency

Source: https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency/
Published: 2026-07-31
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/graphql-dependency 3.1.0 — generated reference, not hand-written

One GraphQL object type's place in the dependency graph — its bulk loader, its optional initializer, and the child types it owns.

**Signature:**

```typescript
export declare class GraphQLDependency<ResultType> 
```

## Remarks

Descriptions are registered one per `GraphQLObjectType` and are never constructed directly: the constructor is `protected`, and [Dependency](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.dependency/) (or [GraphQLDependency.create()](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.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()](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency.defineloader/) — how to fetch this type in bulk; - [GraphQLDependency.require()](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency.require/) — the child types this one owns; - [GraphQLDependency.defineInitializer()](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency.defineinitializer/) — optional pre-fill for fields the dependency filters need but the initial result does not carry.

[GraphQLDependency.load()](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.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 |
| --- | --- | --- |
| [(constructor)(type)](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency._constructor_/) | `protected` | Registers a description against its type. Not called directly — the constructor is `protected` so that [Dependency](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.dependency/) and [GraphQLDependency.create()](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency.create/) stay the only way in, which is what keeps one description per type. |


## Properties


| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [type](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency.type/) | `readonly` | 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 |
| --- | --- | --- |
| [create(type)](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency.create/) | `static` | Returns the dependency description for a GraphQL object type, creating and registering it the first time the type is seen. |
| [defineInitializer(initializer, fields)](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency.defineinitializer/) |  | Declares an async routine that fills extra fields onto this type's own objects before its dependencies are loaded. |
| [defineLoader(loader)](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency.defineloader/) |  | Declares how to fetch many objects of this type in one call, which is what makes the type usable as another type's dependency. |
| [isEmptyArg(filter)](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency.isemptyarg/) | `static` | Reports whether a filter assembled for a loader has nothing left to look up, so the loader can be skipped. |
| [load(source, context, fields)](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency.load/) |  | Loads everything the request asked for beneath this type and attaches it to the result, in as few bulk calls as the graph allows. |
| [require(child, options)](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency.require/) |  | Declares that this type owns a child type, and how the child's objects are found and where they are attached. |

