# GraphQLDependency.require() method · @imqueue/graphql-dependency

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

Declares that this type owns a child type, and how the child's objects are found and where they are attached.

**Signature:**

```typescript
require(child: GraphQLObjectType, ...options: DependencyOptionsGetter[]): GraphQLDependency<ResultType>;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| child | GraphQLObjectType | the child type this type depends on |
| options | [DependencyOptionsGetter](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.dependencyoptionsgetter/)\[\] | one getter per relation to `child` |


**Returns:**

[GraphQLDependency](https://imqueue.org/api/graphql-dependency/latest/graphql-dependency.graphqldependency/)<ResultType>

this description, so calls can be chained

## Remarks

Each requirement is a pair. `as` is the field on \*this\* type the loaded children are written to — whether one child or a list is attached is decided by that field's own GraphQL type. `filter` maps a key of the child's loader filter to the field on \*this\* type whose values fill it, so it reads child-side key first, parent-side source second.

Passing several requirements for one child type is the normal case rather than a special one: a company relating to users as both `owner` and `employees` is two requirements naming `UserType`, differing in `as` and in which field feeds the filter.

Requirements are given as thunks because the types they reference are usually still being defined when this runs — a `GraphQLObjectType` with circular references only has its fields once the schema settles, so the getters are called at request time, not now.

A repeat call for the same child type replaces that type's requirements rather than adding to them; list every relation to a type in one call.

## Example


```typescript
Dependency(CompanyType).require(
    UserType,
    () => ({
        as: CompanyType.getFields().employees,
        filter: {
            [UserType.getFields().companyId.name]:
                CompanyType.getFields().id,
        },
    }),
    () => ({
        as: CompanyType.getFields().owner,
        filter: {
            [UserType.getFields().id.name]:
                CompanyType.getFields().ownerId,
        },
    }),
);
```

