Type alias ResolvedModel<Model, Depth, RecursionLoop>

ResolvedModel<Model, Depth, RecursionLoop>: {
    done: NonRelationshipFields<Model>;
    recur: {
        [Field in keyof Model]: Model[Field] extends ((...args) => ListReturnValue<infer M>)
            ? NonNullable<M> extends Record<string, any>
                ? ResolvedModel<NonNullable<M>, RecursionLoop[Depth]>[]
                : never
            : Model[Field] extends ((...args) => SingularReturnValue<infer M>)
                ? NonNullable<M> extends Record<string, any>
                    ? ResolvedModel<NonNullable<M>, RecursionLoop[Depth]>
                    : never
                : Model[Field]
    };
}[Depth extends -1
    ? "done"
    : "recur"]

Flattens model instance type and unwraps async functions into resolved GraphQL shape

This type is used for generating the base shape for custom selection set input and its return value Uses same pattern as above to limit recursion depth to maximum usable for selection set.

Type Parameters

  • Model extends Record<string, unknown>

  • Depth extends number = 7

  • RecursionLoop extends number[] = [-1, 0, 1, 2, 3, 4, 5, 6]

Example

Given

Model = {
title: string;
comments: () => ListReturnValue<({
content: string;
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
} | null | undefined)[]>;
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
description?: string | ... 1 more ... | undefined;
}

Returns

{
title: string;
comments: {
content: string;
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
}[];
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
description: string | null | undefined;
}