|
1 |
| -import { Field, InterfaceType, ObjectType } from '@nestjs/graphql'; |
| 1 | +import { |
| 2 | + Field, |
| 3 | + InterfaceType, |
| 4 | + ObjectType, |
| 5 | + registerEnumType, |
| 6 | +} from '@nestjs/graphql'; |
| 7 | +import { MadeEnum } from '@seedcompany/nest'; |
2 | 8 | import { stripIndent } from 'common-tags';
|
3 | 9 | import { keys as keysOf } from 'ts-transformer-keys';
|
4 | 10 | import {
|
5 | 11 | EnumType,
|
| 12 | + lazyRef, |
6 | 13 | makeEnum,
|
7 | 14 | Resource,
|
8 | 15 | SecuredProperty,
|
@@ -39,15 +46,21 @@ export abstract class Producible extends Resource {
|
39 | 46 | SetChangeType<'scriptureReferences', readonly ScriptureRangeInput[]>;
|
40 | 47 | }
|
41 | 48 |
|
42 |
| -export type ProducibleType = EnumType<typeof ProducibleType>; |
43 |
| -export const ProducibleType = makeEnum({ |
44 |
| - name: 'ProducibleType', |
45 |
| - values: keysOf<ProducibleTypeEntries>(), |
46 |
| -}); |
47 |
| - |
48 | 49 | // Augment this with each implementation of Producible via declaration merging
|
49 | 50 | // eslint-disable-next-line @typescript-eslint/no-empty-interface
|
50 | 51 | export interface ProducibleTypeEntries {}
|
| 52 | +export const ProducibleTypeEntries = new Set<string>(); |
| 53 | + |
| 54 | +export type ProducibleType = EnumType<typeof ProducibleType>; |
| 55 | +export const ProducibleType = lazyRef( |
| 56 | + (): MadeEnum<keyof ProducibleTypeEntries> => |
| 57 | + (realProducibleType ??= makeEnum({ |
| 58 | + values: ProducibleTypeEntries as Iterable<keyof ProducibleTypeEntries>, |
| 59 | + })), |
| 60 | +); |
| 61 | +let realProducibleType: MadeEnum<keyof ProducibleTypeEntries> | undefined; |
| 62 | +// Register proxy eagerly to GQL schema |
| 63 | +registerEnumType(ProducibleType, { name: 'ProducibleType' }); |
51 | 64 |
|
52 | 65 | export type ProducibleRef = UnsecuredDto<Producible> & {
|
53 | 66 | __typename: ProducibleType;
|
|
0 commit comments