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 | */
|
7 | import { Complexity, FieldMiddleware } from '../interfaces';
|
8 | import { BaseTypeOptions } from '../interfaces/base-type-options.interface';
|
9 | import { GqlTypeReference, ReturnTypeFunc, ReturnTypeFuncValue } from '../interfaces/return-type-func.interface';
|
10 | /**
|
11 | * Interface defining options that can be passed to `@Field()` decorator.
|
12 | */
|
13 | export type FieldOptions<T = any> = BaseTypeOptions<T> & {
|
14 | /**
|
15 | * Name of the field.
|
16 | */
|
17 | name?: string;
|
18 | /**
|
19 | * Description of the field.
|
20 | */
|
21 | description?: string;
|
22 | /**
|
23 | * Field deprecation reason (if deprecated).
|
24 | */
|
25 | deprecationReason?: string;
|
26 | /**
|
27 | * Field complexity options.
|
28 | */
|
29 | complexity?: Complexity;
|
30 | /**
|
31 | * Array of middleware to apply.
|
32 | */
|
33 | middleware?: FieldMiddleware[];
|
34 | };
|
35 | type FieldOptionsExtractor<T> = T extends [GqlTypeReference<infer P>] ? FieldOptions<P[]> : T extends GqlTypeReference<infer P> ? FieldOptions<P> : never;
|
36 | /**
|
37 | * @Field() decorator is used to mark a specific class property as a GraphQL field.
|
38 | * Only properties decorated with this decorator will be defined in the schema.
|
39 | */
|
40 | export declare function Field(): PropertyDecorator & MethodDecorator;
|
41 | /**
|
42 | * @Field() decorator is used to mark a specific class property as a GraphQL field.
|
43 | * Only properties decorated with this decorator will be defined in the schema.
|
44 | */
|
45 | export declare function Field<T extends ReturnTypeFuncValue>(options: FieldOptionsExtractor<T>): PropertyDecorator & MethodDecorator;
|
46 | /**
|
47 | * @Field() decorator is used to mark a specific class property as a GraphQL field.
|
48 | * Only properties decorated with this decorator will be defined in the schema.
|
49 | */
|
50 | export declare function Field<T extends ReturnTypeFuncValue>(returnTypeFunction?: ReturnTypeFunc<T>, options?: FieldOptionsExtractor<T>): PropertyDecorator & MethodDecorator;
|
51 | export declare function addFieldMetadata<T extends ReturnTypeFuncValue>(typeOrOptions: ReturnTypeFunc<T> | FieldOptionsExtractor<T>, fieldOptions: FieldOptionsExtractor<T>, prototype: Object, propertyKey?: string, descriptor?: TypedPropertyDescriptor<any>, loadEagerly?: boolean): void;
|
52 | export {};
|
53 | //# sourceMappingURL=field.decorator.d.ts.map |
\ | No newline at end of file |