UNPKG

1.62 kBTypeScriptView Raw
1/**
2 * The API surface of this module has been heavily inspired by the "type-graphql" library (https://github.com/MichalLytek/type-graphql), originally designed & released by Michal Lytek.
3 * In the v6 major release of NestJS, we introduced the code-first approach as a compatibility layer between this package and the `@nestjs/graphql` module.
4 * Eventually, our team decided to reimplement all the features from scratch due to a lack of flexibility.
5 * To avoid numerous breaking changes, the public API is backward-compatible and may resemble "type-graphql".
6 */
7import { Type } from '@nestjs/common';
8import { ResolveTypeFn } from '../interfaces/resolve-type-fn.interface';
9/**
10 * Interface defining options that can be passed to `createUnionType` function.
11 */
12export interface UnionOptions<T extends readonly Type<unknown>[] = Type<unknown>[]> {
13 /**
14 * Name of the union.
15 */
16 name?: string;
17 /**
18 * Description of the union.
19 */
20 description?: string;
21 /**
22 * Custom implementation of the "resolveType" function.
23 */
24 resolveType?: ResolveTypeFn<any, any>;
25 /**
26 * Types that the union consist of.
27 */
28 types: () => T;
29}
30export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType[number];
31export type Union<T extends readonly any[]> = InstanceType<ArrayElement<T>>;
32/**
33 * Creates a GraphQL union type composed of types references.
34 * @param options
35 */
36export declare function createUnionType<T extends readonly Type<unknown>[] = Type<unknown>[]>(options: UnionOptions<T>): Union<T>;
37//# sourceMappingURL=create-union-type.factory.d.ts.map
\No newline at end of file