@eddeee888/gcg-typescript-resolver-files 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +191 -32
  2. package/package.json +5 -5
  3. package/src/defineConfig.d.ts +5 -0
  4. package/src/defineConfig.js +19 -0
  5. package/src/defineConfig.js.map +1 -0
  6. package/src/generateResolverFiles/addExternalResolverImport.d.ts +1 -0
  7. package/src/generateResolverFiles/addExternalResolverImport.js +1 -0
  8. package/src/generateResolverFiles/addExternalResolverImport.js.map +1 -1
  9. package/src/generateResolverFiles/addResolverMainFile.d.ts +4 -1
  10. package/src/generateResolverFiles/addResolverMainFile.js +71 -50
  11. package/src/generateResolverFiles/addResolverMainFile.js.map +1 -1
  12. package/src/generateResolverFiles/handleGraphQLObjectType.js +2 -1
  13. package/src/generateResolverFiles/handleGraphQLObjectType.js.map +1 -1
  14. package/src/generateResolverFiles/handleGraphQLRootObjectTypeField.js +9 -2
  15. package/src/generateResolverFiles/handleGraphQLRootObjectTypeField.js.map +1 -1
  16. package/src/generateResolverFiles/handleGraphQLScalarType.js +2 -1
  17. package/src/generateResolverFiles/handleGraphQLScalarType.js.map +1 -1
  18. package/src/generateResolverFiles/handleGraphQLUninionType.js +2 -1
  19. package/src/generateResolverFiles/handleGraphQLUninionType.js.map +1 -1
  20. package/src/generateResolverFiles/postProcessFiles.js +2 -1
  21. package/src/generateResolverFiles/postProcessFiles.js.map +1 -1
  22. package/src/generateResolverFiles/types.d.ts +11 -4
  23. package/src/generateResolverFiles/visitNamedType.js +28 -11
  24. package/src/generateResolverFiles/visitNamedType.js.map +1 -1
  25. package/src/generateTypeDefsFiles/generateTypeDefsContent.js.map +1 -0
  26. package/src/generateTypeDefsFiles/generateTypeDefsFiles.d.ts +13 -0
  27. package/src/generateTypeDefsFiles/generateTypeDefsFiles.js +60 -0
  28. package/src/generateTypeDefsFiles/generateTypeDefsFiles.js.map +1 -0
  29. package/src/generateTypeDefsFiles/index.d.ts +1 -0
  30. package/src/{generateTypeDefsContent → generateTypeDefsFiles}/index.js +1 -1
  31. package/src/{generateTypeDefsContent → generateTypeDefsFiles}/index.js.map +1 -1
  32. package/src/getGraphQLObjectTypeResolversToGenerate/getGraphQLObjectTypeResolversToGenerate.d.ts +1 -1
  33. package/src/index.d.ts +1 -0
  34. package/src/index.js +3 -1
  35. package/src/index.js.map +1 -1
  36. package/src/parseGraphQLSchema/index.d.ts +1 -0
  37. package/src/{getPluginsConfig → parseGraphQLSchema}/index.js +1 -1
  38. package/src/parseGraphQLSchema/index.js.map +1 -0
  39. package/src/{getPluginsConfig/getPluginsConfig.d.ts → parseGraphQLSchema/parseGraphQLSchema.d.ts} +2 -5
  40. package/src/{getPluginsConfig/getPluginsConfig.js → parseGraphQLSchema/parseGraphQLSchema.js} +4 -7
  41. package/src/parseGraphQLSchema/parseGraphQLSchema.js.map +1 -0
  42. package/src/parseSources/parseSources.d.ts +0 -1
  43. package/src/parseSources/parseSources.js +2 -3
  44. package/src/parseSources/parseSources.js.map +1 -1
  45. package/src/parseTypeMappers/collectTypeMappersFromSourceFile.js +13 -2
  46. package/src/parseTypeMappers/collectTypeMappersFromSourceFile.js.map +1 -1
  47. package/src/parseTypeMappers/parseTypeMappers.d.ts +1 -1
  48. package/src/parseTypeMappers/parseTypeMappers.js +1 -1
  49. package/src/parseTypeMappers/parseTypeMappers.js.map +1 -1
  50. package/src/preset.js +28 -20
  51. package/src/preset.js.map +1 -1
  52. package/src/utils/cwd.d.ts +4 -0
  53. package/src/utils/cwd.js +12 -0
  54. package/src/utils/cwd.js.map +1 -0
  55. package/src/utils/getNodePropertyMap.d.ts +1 -1
  56. package/src/utils/getNodePropertyMap.js +23 -15
  57. package/src/utils/getNodePropertyMap.js.map +1 -1
  58. package/src/utils/index.d.ts +4 -2
  59. package/src/utils/index.js +4 -16
  60. package/src/utils/index.js.map +1 -1
  61. package/src/utils/isRootObjectType.d.ts +1 -1
  62. package/src/utils/isWhitelistedModule.d.ts +5 -0
  63. package/src/utils/isWhitelistedModule.js +16 -0
  64. package/src/utils/isWhitelistedModule.js.map +1 -0
  65. package/src/utils/normalizeRelativePath.d.ts +1 -0
  66. package/src/utils/normalizeRelativePath.js +11 -0
  67. package/src/utils/normalizeRelativePath.js.map +1 -0
  68. package/src/utils/parseLocationForWhitelistedModule.js +7 -9
  69. package/src/utils/parseLocationForWhitelistedModule.js.map +1 -1
  70. package/src/utils/relativeModulePath.d.ts +1 -0
  71. package/src/utils/relativeModulePath.js +11 -0
  72. package/src/utils/relativeModulePath.js.map +1 -0
  73. package/src/validatePresetConfig/validatePresetConfig.d.ts +19 -5
  74. package/src/validatePresetConfig/validatePresetConfig.js +40 -19
  75. package/src/validatePresetConfig/validatePresetConfig.js.map +1 -1
  76. package/src/generateTypeDefsContent/generateTypeDefsContent.js.map +0 -1
  77. package/src/generateTypeDefsContent/index.d.ts +0 -1
  78. package/src/getPluginsConfig/getPluginsConfig.js.map +0 -1
  79. package/src/getPluginsConfig/index.d.ts +0 -1
  80. package/src/getPluginsConfig/index.js.map +0 -1
  81. /package/src/{generateTypeDefsContent → generateTypeDefsFiles}/generateTypeDefsContent.d.ts +0 -0
  82. /package/src/{generateTypeDefsContent → generateTypeDefsFiles}/generateTypeDefsContent.js +0 -0
package/README.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  This [GraphQL Code Generator](https://www.the-guild.dev/graphql/codegen) plugin creates resolvers given GraphQL schema.
4
4
 
5
- This relies on types generated from [typescript](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript) and [@graphql-codegen/typescript-resolvers](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-resolvers) plugins.
5
+ This relies on types generated from [@graphql-codegen/typescript](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript) and [@graphql-codegen/typescript-resolvers](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-resolvers) plugins.
6
6
 
7
7
  ```bash
8
- yarn add -D @eddeee888/gcg-typescript-resolver-files
8
+ yarn add -D @graphql-codegen/cli @eddeee888/gcg-typescript-resolver-files
9
9
  yarn add graphql-scalars
10
10
  ```
11
11
 
@@ -17,17 +17,19 @@ yarn add graphql-scalars
17
17
  - Automatically sets up GraphQL Scalars with types and config from [graphql-scalars](https://github.com/Urigo/graphql-scalars) with ability to opt-out
18
18
  - Automatically extracts object type mapper interfaces and types (marked with `Mapper` suffix) from accompanying `.mappers.ts` files in each module. For example, if the schema file is `/path/to/schema.graphql`, the mapper file is `/path/to/schema.mappers.ts`.
19
19
 
20
- ## Example
20
+ ## Getting Started
21
21
 
22
22
  ### Setup
23
23
 
24
+ #### Files
25
+
24
26
  ```graphql
25
- # src/graphql/modules/base/schema.graphqls
27
+ # src/schema/base/schema.graphql
26
28
  type Query
27
29
  ```
28
30
 
29
31
  ```graphql
30
- # src/graphql/modules/user/schema.graphqls
32
+ # src/schema/user/schema.graphql
31
33
  extend type Query {
32
34
  user(id: ID!): User
33
35
  }
@@ -44,7 +46,7 @@ type Address {
44
46
  ```
45
47
 
46
48
  ````ts
47
- // src/graphql/modules/user/schema.mappers.graphqls
49
+ // src/schema/user/schema.mappers.ts
48
50
 
49
51
  // Exporting the following Mapper interfaces and types is the equivalent of this codegen config:
50
52
  // ```yml
@@ -62,39 +64,196 @@ export interface UserMapper {
62
64
  }
63
65
  ````
64
66
 
67
+ #### Codegen Config
68
+
69
+ ```ts
70
+ // codegen.ts
71
+ import { defineConfig } from '@eddeee888/gcg-typescript-resolver-files';
72
+ const config: CodegenConfig = {
73
+ schema: '**/schema.graphql',
74
+ generates: {
75
+ 'src/schema': defineConfig(),
76
+ },
77
+ };
78
+ export default config;
79
+ ```
80
+
81
+ OR
82
+
65
83
  ```yml
66
84
  # codegen.yml
67
- schema: '**/*.graphqls'
85
+ schema: '**/*.graphql'
68
86
  generates:
69
- src/graphql/modules:
87
+ src/schema:
70
88
  preset: '@eddeee888/gcg-typescript-resolver-files'
89
+ watchPattern: '**/*.mappers.ts'
71
90
  ```
72
91
 
73
92
  ### Result
74
93
 
75
94
  Running codegen will generate the following files:
76
95
 
77
- - `src/graphql/modules/user/resolvers/Query/user.ts`
78
- - `src/graphql/modules/user/resolvers/User.ts`
79
- - `src/graphql/modules/user/resolvers/Address.ts`
80
- - `src/graphql/modules/resolvers.generated.ts`
81
- - `src/graphql/modules/typeDefs.generated.ts`
82
- - `src/graphql/modules/types.generated.ts`
83
-
84
- ## Config
85
-
86
- | Name | Type | Description |
87
- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
88
- | `mode` | `merged` or `modules` | (Default: `modules`) How files are collocated. `modules` detects containing dir of a schema file as "modules", then split resolvers into those modules. `merged` treats `baseOutputDir` as the one and only module and generates resolvers. |
89
- | `resolverTypesPath` | `string` | (Default: `./types.generated.ts`) Relative path to type file generated by `typescript-resolvers` plugin. |
90
- | `resolverRelativeTargetDir` | `string` | (Default: `resolvers`) Relative path to target dir. For `config.mode=merged`, files will be generated into `<baseOutputDir>/<resolverRelativeTargetDir>`. For `config.mode=modules`, files will be generated into `<baseOutputDir>/<moduleName>/<resolverRelativeTargetDir>` |
91
- | `resolverMainFile` | `string` | (Default: `resolvers.generated.ts`) File that puts all generated resolvers together. Relative from `baseOutputDir` |
92
- | `typeDefsFilePath` | `string` or `boolean` | (Default: `./typeDefs.generated.ts`) Merged type defs from all sources. Relative from `baseOutputDir`. If value is `false` or empty string, the file is not generated. |
93
- | `whitelistedModules` | `Array<string>` | (Only works with `config.mode=modules`) Whitelists modules to generate files and entries in main file. By default all modules are whitelisted. Useful for gradual migrations. |
94
- | `blacklistedModules` | `Array<string>` | (Only works with `config.mode=modules`) Blacklists modules to avoid generate files and entries in main file. Useful for gradual migrations. |
95
- | `externalResolvers` | `Record<string, string>` | Map of relative or absolute path (prefixed with `~`) to external or existing resolvers. e.g. `DateTime: ~graphql-scalars#DateTimeResolver`, `Query.me: '~@org/meResolver#default as meResolver'`, `User: 'otherResolvers#User as UserResolver'`. |
96
- | `typesPluginsConfig` | `(@graphql-codegen/typescript).TypeScriptPluginConfig & (@graphql-codegen/typescript-resolvers).TypeScriptResolversPluginConfig` | Takes [typescript config](https://www.the-guild.dev/graphql/codegen/plugins/typescript/typescript) and [typescript-resolvers config](https://www.the-guild.dev/graphql/codegen/plugins/typescript/typescript-resolvers) to override the defaults |
97
- | `mappersFileExtension` | `string` | (Default: `.mappers.ts`) The files with this extension provides mappers interfaces and types for the schema files in the same dir. |
98
- | `mappersSuffix` | `string` | (Default: `Mapper`) Exported interfaces and types with this suffix from `mappersFile` in each module are put into the mappers object of [@graphql-codegen/typescript-resolvers](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-resolvers) . |
99
- | `tsConfigFilePath` | `string` | (Default: `./tsconfig.json`) Project's TypeScript config, relative from project root. This helps type analysis such as resolving custom module paths. |
100
- | `fixObjectTypeResolvers` | `smart` or `disabled` | (Default: `smart`) (Experimental) Statically compares object type's mapper types' field against schema types' fields, creating resolvers if required |
96
+ - `src/schema/user/resolvers/Query/user.ts`
97
+ - `src/schema/user/resolvers/User.ts`
98
+ - `src/schema/user/resolvers/Address.ts`
99
+ - `src/schema/resolvers.generated.ts`
100
+ - `src/schema/typeDefs.generated.ts`
101
+ - `src/schema/types.generated.ts`
102
+
103
+ ## Config Options
104
+
105
+ ### mode
106
+
107
+ `merged` or `modules` (Default: `modules`)
108
+
109
+ How files are collocated. `modules` detects containing dir of a schema file as "modules", then split resolvers into those modules. `merged` treats `baseOutputDir` as the one and only module and generates resolvers.
110
+
111
+ ### resolverTypesPath
112
+
113
+ `string` (Default: `./types.generated.ts`)
114
+
115
+ Relative path to type file generated by `typescript-resolvers` plugin.
116
+
117
+ ### resolverRelativeTargetDir
118
+
119
+ `string` (Default: `resolvers`)
120
+
121
+ Relative path to target dir. For `config.mode=merged`, files will be generated into `<baseOutputDir>/<resolverRelativeTargetDir>`. For `config.mode=modules`, files will be generated into `<baseOutputDir>/<moduleName>/<resolverRelativeTargetDir>`.
122
+
123
+ ### resolverMainFileMode
124
+
125
+ `merged` or `modules` (Default: `merged`)
126
+
127
+ How to generate file/s that put resolvers map together:
128
+
129
+ - `merged`: one file
130
+ - `modules`: one file per module
131
+
132
+ ### resolverMainFile
133
+
134
+ `string` (Default: `resolvers.generated.ts`)
135
+
136
+ File that puts all generated resolvers together. Relative from `baseOutputDir`.
137
+
138
+ ### typeDefsFileMode
139
+
140
+ `merged` or `mergedWhitelisted` or `modules` (Default: `merged`)
141
+
142
+ How to generate typeDefs file/s:
143
+
144
+ - `merged`: one file
145
+ - `mergedWhitelisted`: one file but only contains whitelisted modules
146
+ - `modules`: one file per module
147
+
148
+ If `config.mode=merged`, this config is always `merged`
149
+
150
+ ### typeDefsFilePath
151
+
152
+ `string` or `false` (Default: `./typeDefs.generated.ts`)
153
+
154
+ Where to generate typeDefs files. If value is `false` or empty string, the file/s are not generated.
155
+
156
+ If `typeDefsFileMode=merged` or `typeDefsFileMode=mergedWhitelisted`, this path is relative from `baseOutputDir`.
157
+
158
+ If `typeDefsFileMode=modules`, this path is relative from each module directory.
159
+
160
+ ### whitelistedModules
161
+
162
+ `Array<string>` (Only works with `config.mode=modules`)
163
+
164
+ Whitelists modules to generate files and entries in main file. By default all modules are whitelisted. Useful for gradual migrations.
165
+
166
+ ### blacklistedModules
167
+
168
+ `Array<string>` (Only works with `config.mode=modules`)
169
+
170
+ Blacklists modules to avoid generate files and entries in main file. Useful for gradual migrations.
171
+
172
+ ### externalResolvers
173
+
174
+ `Record<string, string>`
175
+
176
+ Map of relative or absolute path (prefixed with `~`) to external or existing resolvers.
177
+
178
+ Examples:
179
+
180
+ - `DateTime: ~graphql-scalars#DateTimeResolver`
181
+ - `Query.me: '~@org/meResolver#default as meResolver'`
182
+ - `User: 'otherResolvers#User as UserResolver'`.
183
+
184
+ ### typesPluginsConfig
185
+
186
+ `(@graphql-codegen/typescript).TypeScriptPluginConfig & (@graphql-codegen/typescript-resolvers).TypeScriptResolversPluginConfig`
187
+
188
+ Takes [typescript config](https://www.the-guild.dev/graphql/codegen/plugins/typescript/typescript) and [typescript-resolvers config](https://www.the-guild.dev/graphql/codegen/plugins/typescript/typescript-resolvers) to override the defaults.
189
+
190
+ ### mappersFileExtension
191
+
192
+ `string` (Default: `.mappers.ts`)
193
+
194
+ The files with this extension provides mappers interfaces and types for the schema files in the same module.
195
+
196
+ ### mappersSuffix
197
+
198
+ `string` (Default: `Mapper`)
199
+
200
+ Exported interfaces and types with this suffix from `mappersFile` in each module are put into the mappers object of [@graphql-codegen/typescript-resolvers](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-resolvers).
201
+
202
+ ### tsConfigFilePath
203
+
204
+ `string` (Default: `./tsconfig.json`)
205
+
206
+ Project's TypeScript config, relative from project root. This helps type analysis such as resolving custom module paths.
207
+
208
+ ### fixObjectTypeResolvers
209
+
210
+ `smart` or `disabled` (Default: `smart`) (Experimental)
211
+
212
+ Statically compares object type's mapper types' field against schema types' fields, creating resolvers if required
213
+
214
+ ## Config Examples
215
+
216
+ #### 1. Custom Config
217
+
218
+ Custom preset config can be set using the `presetConfig` option:
219
+
220
+ ```yml
221
+ # codegen.yml
222
+ schema: '**/*.graphql'
223
+ generates:
224
+ src/schema:
225
+ preset: '@eddeee888/gcg-typescript-resolver-files'
226
+ presetConfig:
227
+ mode: 'modules'
228
+ resolverTypesPath: './types.gen.ts'
229
+ typeDefsFilePath: false
230
+ typesPluginsConfig: # Pass config you'd normally use for `typescript` and `typescript-resolvers` here
231
+ nonOptionalTypename: false
232
+ federation: true
233
+ ```
234
+
235
+ #### 2. Using TypeScript Config File
236
+
237
+ If you use `codegen.ts`, you can use the exported `defineConfig` function to get better TypeScript support:
238
+
239
+ ```ts
240
+ import type { CodegenConfig } from '@graphql-codegen/cli';
241
+ import { defineConfig } from '@eddeee888/gcg-typescript-resolver-files';
242
+
243
+ const config: CodegenConfig = {
244
+ schema: '**/schema.graphql',
245
+ generates: {
246
+ 'src/schema': defineConfig({
247
+ mode: 'modules',
248
+ resolverTypesPath: './types.gen.ts',
249
+ typeDefsFilePath: false,
250
+ typesPluginsConfig: {
251
+ // Pass config you'd normally use for `typescript` and `typescript-resolvers` here
252
+ nonOptionalTypename: false,
253
+ federation: true,
254
+ },
255
+ }),
256
+ },
257
+ };
258
+ export default config;
259
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eddeee888/gcg-typescript-resolver-files",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/eddeee888/graphql-code-generator-plugins.git",
@@ -28,11 +28,11 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@graphql-codegen/add": "^4.0.0",
31
- "@graphql-codegen/plugin-helpers": "^4.0.0",
32
- "@graphql-codegen/typescript": "^3.0.0",
33
- "@graphql-codegen/typescript-resolvers": "^3.0.0",
31
+ "@graphql-codegen/plugin-helpers": "^4.2.0",
32
+ "@graphql-codegen/typescript": "^3.0.3",
33
+ "@graphql-codegen/typescript-resolvers": "^3.2.0",
34
34
  "graphql-scalars": "^1.20.1",
35
- "ts-morph": "^16.0.0"
35
+ "ts-morph": "^18.0.0"
36
36
  },
37
37
  "publishConfig": {
38
38
  "directory": "../../dist/packages/typescript-resolver-files"
@@ -0,0 +1,5 @@
1
+ import type { Types } from '@graphql-codegen/plugin-helpers';
2
+ import type { TypedPresetConfig } from './validatePresetConfig';
3
+ export declare const defineConfig: (presetConfig?: TypedPresetConfig, context?: {
4
+ baseOutputDir: string;
5
+ }) => Pick<Types.ConfiguredOutput, 'preset' | 'presetConfig' | 'watchPattern'>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineConfig = void 0;
4
+ const path = require("path");
5
+ const preset_1 = require("./preset");
6
+ const defineConfig = (presetConfig = {}, context = { baseOutputDir: '' }) => {
7
+ const { baseOutputDir } = context;
8
+ const mappersFileExtension = presetConfig.mappersFileExtension || '.mappers.ts';
9
+ const watchPattern = [];
10
+ const mapperWatchPattern = path.posix.join(baseOutputDir, '**', `*${mappersFileExtension}`);
11
+ watchPattern.push(mapperWatchPattern);
12
+ return {
13
+ preset: preset_1.preset,
14
+ presetConfig,
15
+ watchPattern,
16
+ };
17
+ };
18
+ exports.defineConfig = defineConfig;
19
+ //# sourceMappingURL=defineConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineConfig.js","sourceRoot":"","sources":["../../../../packages/typescript-resolver-files/src/defineConfig.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAG7B,qCAAkC;AAE3B,MAAM,YAAY,GAAG,CAC1B,eAAkC,EAAE,EACpC,UAAqC,EAAE,aAAa,EAAE,EAAE,EAAE,EACgB,EAAE;IAC5E,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAElC,MAAM,oBAAoB,GACxB,YAAY,CAAC,oBAAoB,IAAI,aAAa,CAAC;IAErD,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CACxC,aAAa,EACb,IAAI,EACJ,IAAI,oBAAoB,EAAE,CAC3B,CAAC;IACF,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAEtC,OAAO;QACL,MAAM,EAAN,eAAM;QACN,YAAY;QACZ,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AAtBW,QAAA,YAAY,gBAsBvB"}
@@ -1,5 +1,6 @@
1
1
  import type { GenerateResolverFilesContext } from './types';
2
2
  interface AddExternalResolverImportParams {
3
+ moduleName: string;
3
4
  normalizedResolverName: string;
4
5
  configImportSyntax: string;
5
6
  }
@@ -7,6 +7,7 @@ const addExternalResolverImport = (params, { result }) => {
7
7
  result.externalImports[moduleImport] =
8
8
  result.externalImports[moduleImport] ||
9
9
  {
10
+ moduleName: params.moduleName,
10
11
  importLineMeta: {
11
12
  isTypeImport: false,
12
13
  module: moduleImport,
@@ -1 +1 @@
1
- {"version":3,"file":"addExternalResolverImport.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/generateResolverFiles/addExternalResolverImport.ts"],"names":[],"mappings":";;;AAAA,oCAAiD;AAa1C,MAAM,yBAAyB,GAAG,CACvC,MAAuC,EACvC,EAAE,MAAM,EAAgC,EAClC,EAAE;IACR,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,GACvD,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAE5B,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC;QAClC,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC;YACnC;gBACC,cAAc,EAAE;oBACd,YAAY,EAAE,KAAK;oBACnB,MAAM,EAAE,YAAY;oBACpB,YAAY,EAAE,EAAE;oBAChB,aAAa,EAAE,SAAS;iBACzB;gBACD,gBAAgB,EAAE,EAAE;aACiD,CAAC;IAE1E,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAE5D,QAAQ,gBAAgB,CAAC,MAAM,EAAE;QAC/B,KAAK,SAAS;YACZ,IACE,cAAc,CAAC,cAAc,CAAC,aAAa;gBAC3C,cAAc,CAAC,cAAc,CAAC,aAAa;oBACzC,gBAAgB,CAAC,aAAa,EAChC;gBACA,MAAM,IAAI,KAAK,CACb,8CAA8C,YAAY,eAAe,cAAc,CAAC,cAAc,CAAC,aAAa,UAAU,gBAAgB,CAAC,aAAa,EAAE,CAC/J,CAAC;aACH;YACD,cAAc,CAAC,cAAc,CAAC,aAAa;gBACzC,gBAAgB,CAAC,aAAa,CAAC;YACjC,MAAM;QACR,KAAK,OAAO;YACV,cAAc,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAC7C,gBAAgB,CAAC,WAAW,CAC7B,CAAC;YACF,MAAM;QACR,KAAK,gBAAgB;YACnB,cAAc,CAAC,cAAc,CAAC,Y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aACvB;YACD,YAAY;SACb,CAAC;KACH;IAED,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACxD,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE;QACjC,OAAO;YACL,gBAAgB,EAAE;gBAChB,MAAM,EAAE,OAAO;gBACf,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC;aACjC;YACD,eAAe,EAAE;gBACf,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAC;gBACnC,sBAAsB;aACvB;YACD,YAAY;SACb,CAAC;KACH;IAED,OAAO;QACL,gBAAgB,EAAE;YAChB,MAAM,EAAE,gBAAgB;YACxB,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC;YACjC,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAC;SACpC;QACD,eAAe,EAAE;YACf,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAC;YACnC,sBAAsB;SACvB;QACD,YAAY;KACb,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"addExternalResolverImport.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/generateResolverFiles/addExternalResolverImport.ts"],"names":[],"mappings":";;;AAAA,oCAAiD;AAc1C,MAAM,yBAAyB,GAAG,CACvC,MAAuC,EACvC,EAAE,MAAM,EAAgC,EAClC,EAAE;IACR,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,GACvD,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAE5B,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC;QAClC,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC;YACnC;gBACC,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,cAAc,EAAE;oBACd,YAAY,EAAE,KAAK;oBACnB,MAAM,EAAE,YAAY;oBACpB,YAAY,EAAE,EAAE;oBAChB,aAAa,EAAE,SAAS;iBACzB;gBACD,gBAAgB,EAAE,EAAE;aACiD,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AAY;KACb,CAAC;AACJ,CAAC,CAAC"}
@@ -1,2 +1,5 @@
1
1
  import type { GenerateResolverFilesContext } from './types';
2
- export declare const addResolverMainFile: ({ config: { baseOutputDir, resolverTypesPath, resolverMainFile }, result, }: GenerateResolverFilesContext) => void;
2
+ /**
3
+ * TODO: rename addResolverMainFiles
4
+ */
5
+ export declare const addResolverMainFile: ({ config: { baseOutputDir, resolverTypesPath, resolverMainFile, resolverMainFileMode, }, result, }: GenerateResolverFilesContext) => void;
@@ -3,23 +3,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addResolverMainFile = void 0;
4
4
  const path = require("path");
5
5
  const utils_1 = require("../utils");
6
- const addResolverMainFile = ({ config: { baseOutputDir, resolverTypesPath, resolverMainFile }, result, }) => {
7
- const filename = path.join(baseOutputDir, resolverMainFile.split('/').join(path.sep));
8
- const outputDir = path.dirname(filename);
9
- const relativePathToResolverTypes = (0, utils_1.relativeModulePath)(outputDir, resolverTypesPath);
10
- const resolversDetails = Object.entries(result.files).reduce((res, [filepath, file]) => {
6
+ const createDefaultFileDetails = () => ({
7
+ importLines: [],
8
+ queryFields: [],
9
+ mutationFields: [],
10
+ subscriptionFields: [],
11
+ objectTypes: [],
12
+ });
13
+ /**
14
+ * TODO: rename addResolverMainFiles
15
+ */
16
+ const addResolverMainFile = ({ config: { baseOutputDir, resolverTypesPath, resolverMainFile, resolverMainFileMode, }, result, }) => {
17
+ const resolverMainFiles = Object.entries(result.files).reduce((res, [filepath, file]) => {
11
18
  if (file.__filetype === 'file') {
12
19
  return res;
13
20
  }
21
+ const { meta } = file;
22
+ // If resolverMainFileMode === 'modules', generate main resolver files into modules, otherwise, do it at baseOutputDir
23
+ const resolverMainFilename = resolverMainFileMode === 'modules'
24
+ ? path.posix.join(baseOutputDir, meta.moduleName, resolverMainFile)
25
+ : path.posix.join(baseOutputDir, resolverMainFile);
26
+ const outputDir = path.dirname(resolverMainFilename);
27
+ if (!res[resolverMainFilename]) {
28
+ res[resolverMainFilename] = createDefaultFileDetails();
29
+ }
14
30
  // Non Root Object fields that was generated
15
31
  if (file.__filetype === 'objectType' ||
16
32
  file.__filetype === 'generalResolver') {
17
- res.importLines.push((0, utils_1.printImportLine)({
33
+ res[resolverMainFilename].importLines.push((0, utils_1.printImportLine)({
18
34
  isTypeImport: false,
19
35
  module: (0, utils_1.relativeModulePath)(outputDir, filepath),
20
36
  namedImports: [file.mainImportIdentifier],
21
37
  }));
22
- res.objectTypes.push({
38
+ res[resolverMainFilename].objectTypes.push({
23
39
  propertyName: file.mainImportIdentifier,
24
40
  identifierName: file.mainImportIdentifier,
25
41
  });
@@ -33,27 +49,28 @@ const addResolverMainFile = ({ config: { baseOutputDir, resolverTypesPath, resol
33
49
  propertyName: file.mainImportIdentifier,
34
50
  identifierName,
35
51
  };
36
- res.importLines.push((0, utils_1.printImportLine)({
52
+ res[resolverMainFilename].importLines.push((0, utils_1.printImportLine)({
37
53
  isTypeImport: false,
38
54
  module: (0, utils_1.relativeModulePath)(outputDir, filepath),
39
55
  namedImports: [fieldMapping],
40
56
  }));
41
57
  const rootObjectMap = {
42
- Query: () => res.queryFields.push(fieldMapping),
43
- Mutation: () => res.mutationFields.push(fieldMapping),
44
- Subscription: () => res.subscriptionFields.push(fieldMapping),
58
+ Query: () => res[resolverMainFilename].queryFields.push(fieldMapping),
59
+ Mutation: () => res[resolverMainFilename].mutationFields.push(fieldMapping),
60
+ Subscription: () => res[resolverMainFilename].subscriptionFields.push(fieldMapping),
45
61
  };
46
62
  rootObjectMap[file.meta.belongsToRootObject]();
47
63
  return res;
48
- }, {
49
- importLines: [],
50
- queryFields: [],
51
- mutationFields: [],
52
- subscriptionFields: [],
53
- objectTypes: [],
54
- });
64
+ }, {});
55
65
  Object.entries(result.externalImports).reduce((res, [module, meta]) => {
56
- res.importLines.push((0, utils_1.printImportLine)({
66
+ // If resolverMainFileMode === 'modules', generate main resolver files into modules, otherwise, do it at baseOutputDir
67
+ const resolverMainFilename = resolverMainFileMode === 'modules'
68
+ ? path.posix.join(baseOutputDir, meta.moduleName, resolverMainFile)
69
+ : path.posix.join(baseOutputDir, resolverMainFile);
70
+ if (!res[resolverMainFilename]) {
71
+ res[resolverMainFilename] = createDefaultFileDetails();
72
+ }
73
+ res[resolverMainFilename].importLines.push((0, utils_1.printImportLine)({
57
74
  isTypeImport: false,
58
75
  module,
59
76
  namedImports: meta.importLineMeta.namedImports,
@@ -63,7 +80,7 @@ const addResolverMainFile = ({ config: { baseOutputDir, resolverTypesPath, resol
63
80
  const resolverNameParts = usage.normalizedResolverName.split('.');
64
81
  // Only 1 part, this is a GraphQL ObjectType
65
82
  if (resolverNameParts.length === 1) {
66
- res.objectTypes.push({
83
+ res[resolverMainFilename].objectTypes.push({
67
84
  propertyName: resolverNameParts[0],
68
85
  identifierName: usage.identifierName,
69
86
  });
@@ -79,48 +96,52 @@ const addResolverMainFile = ({ config: { baseOutputDir, resolverTypesPath, resol
79
96
  propertyName: field,
80
97
  };
81
98
  const rootObjectMap = {
82
- Query: () => res.queryFields.push(fieldMapping),
83
- Mutation: () => res.mutationFields.push(fieldMapping),
84
- Subscription: () => res.subscriptionFields.push(fieldMapping),
99
+ Query: () => res[resolverMainFilename].queryFields.push(fieldMapping),
100
+ Mutation: () => res[resolverMainFilename].mutationFields.push(fieldMapping),
101
+ Subscription: () => res[resolverMainFilename].subscriptionFields.push(fieldMapping),
85
102
  };
86
103
  rootObjectMap[rootObjectType]();
87
104
  });
88
105
  return res;
89
- }, resolversDetails);
106
+ }, resolverMainFiles);
90
107
  const resolversIdentifier = 'resolvers';
91
108
  const resolversTypeName = 'Resolvers'; // Generated type from typescript-resolvers plugin
92
- const queries = resolversDetails.queryFields.length > 0
93
- ? `Query: { ${resolversDetails.queryFields
94
- .map(printObjectMapping)
95
- .join(',')} },`
96
- : '';
97
- const mutations = resolversDetails.mutationFields.length > 0
98
- ? `Mutation: { ${resolversDetails.mutationFields
99
- .map(printObjectMapping)
100
- .join(',')} },`
101
- : '';
102
- const suscriptions = resolversDetails.subscriptionFields.length > 0
103
- ? `Subscription: { ${resolversDetails.subscriptionFields
104
- .map(printObjectMapping)
105
- .join(',')} },`
106
- : '';
107
- result.files[filename] = {
108
- __filetype: 'file',
109
- content: `/* This file was automatically generated. DO NOT UPDATE MANUALLY. */
109
+ Object.entries(resolverMainFiles).forEach(([resolverMainFilename, resolverMainFile]) => {
110
+ const outputDir = path.dirname(resolverMainFilename);
111
+ const relativePathToResolverTypes = (0, utils_1.relativeModulePath)(outputDir, resolverTypesPath);
112
+ const queries = resolverMainFile.queryFields.length > 0
113
+ ? `Query: { ${resolverMainFile.queryFields
114
+ .map(printObjectMapping)
115
+ .join(',')} },`
116
+ : '';
117
+ const mutations = resolverMainFile.mutationFields.length > 0
118
+ ? `Mutation: { ${resolverMainFile.mutationFields
119
+ .map(printObjectMapping)
120
+ .join(',')} },`
121
+ : '';
122
+ const suscriptions = resolverMainFile.subscriptionFields.length > 0
123
+ ? `Subscription: { ${resolverMainFile.subscriptionFields
124
+ .map(printObjectMapping)
125
+ .join(',')} },`
126
+ : '';
127
+ result.files[resolverMainFilename] = {
128
+ __filetype: 'file',
129
+ content: `/* This file was automatically generated. DO NOT UPDATE MANUALLY. */
110
130
  ${(0, utils_1.printImportLine)({
111
- isTypeImport: true,
112
- module: relativePathToResolverTypes,
113
- namedImports: [resolversTypeName],
114
- })}
115
- ${resolversDetails.importLines.map((line) => line).join('\n')}
131
+ isTypeImport: true,
132
+ module: relativePathToResolverTypes,
133
+ namedImports: [resolversTypeName],
134
+ })}
135
+ ${resolverMainFile.importLines.map((line) => line).join('\n')}
116
136
  export const ${resolversIdentifier}: ${resolversTypeName} = {
117
137
  ${queries}
118
138
  ${mutations}
119
139
  ${suscriptions}
120
- ${resolversDetails.objectTypes.map(printObjectMapping).join(',\n')}
140
+ ${resolverMainFile.objectTypes.map(printObjectMapping).join(',\n')}
121
141
  }`,
122
- mainImportIdentifier: resolversIdentifier,
123
- };
142
+ mainImportIdentifier: resolversIdentifier,
143
+ };
144
+ });
124
145
  };
125
146
  exports.addResolverMainFile = addResolverMainFile;
126
147
  const printObjectMapping = ({ propertyName, identifierName, }) => `${propertyName}: ${identifierName}`;
@@ -1 +1 @@
1
- {"version":3,"file":"addResolverMainFile.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/generateResolverFiles/addResolverMainFile.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,oCAKkB;AAGX,MAAM,mBAAmB,GAAG,CAAC,EAClC,MAAM,EAAE,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,EAC9D,MAAM,GACuB,EAAQ,EAAE;IACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CACxB,aAAa,EACb,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAC3C,CAAC;IACF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEzC,MAAM,2BAA2B,GAAG,IAAA,0BAAkB,EACpD,SAAS,EACT,iBAAiB,CAClB,CAAC;IAEF,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAO1D,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;QACxB,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM,EAAE;YAC9B,OAAO,GAAG,CAAC;SACZ;QAED,4CAA4C;QAC5C,IACE,IAAI,CAAC,UAAU,KAAK,YAAY;YAChC,IAAI,CAAC,UAAU,KAAK,iBAAiB,EACrC;YACA,GAAG,CAAC,WAAW,CAAC,IAAI,CAClB,IAAA,uBAAe,EAAC;gBACd,YAAY,EAAE,KAAK;gBACnB,MAAM,EAAE,IAAA,0BAAkB,EAAC,SAAS,EAAE,QAAQ,CAAC;gBAC/C,YAAY,EAAE,CAAC,IAAI,CAAC,oBAA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,mBAAmB,KAAK,iBAAiB;QACpD,OAAO;QACP,SAAS;QACT,YAAY;QACZ,gBAAgB,CAAC,WAAW,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;MAClE;QACF,oBAAoB,EAAE,mBAAmB;KAC1C,CAAC;AACJ,CAAC,CAAC;AAlKW,QAAA,mBAAmB,uBAkK9B;AAMF,MAAM,kBAAkB,GAAG,CAAC,EAC1B,YAAY,EACZ,cAAc,GACK,EAAU,EAAE,CAAC,GAAG,YAAY,KAAK,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"addResolverMainFile.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/generateResolverFiles/addResolverMainFile.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,oCAKkB;AAUlB,MAAM,wBAAwB,GAAG,GAAgB,EAAE,CAAC,CAAC;IACnD,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,EAAE;IACf,cAAc,EAAE,EAAE;IAClB,kBAAkB,EAAE,EAAE;IACtB,WAAW,EAAE,EAAE;CAChB,CAAC,CAAC;AAEH;;GAEG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAClC,MAAM,EAAE,EACN,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,GACrB,EACD,MAAM,GACuB,EAAQ,EAAE;IACvC,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAE3D,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;QAC1B,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM,EAAE;YAC9B,OAAO,GAAG,CAAC;SACZ;QAED,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEtB,sHAAsH;QACtH,MAAM,oBAAoB,GACxB,oBAAoB,KAAK,SAAS;YAChC,CAAC,CAAC,IAAI,CAAC,KAAK,CAA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BAAiB,CAAC;aAClC,CAAC;MACA,gBAAgB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;mBAC9C,mBAAmB,KAAK,iBAAiB;QACpD,OAAO;QACP,SAAS;QACT,YAAY;QACZ,gBAAgB,CAAC,WAAW,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;MAClE;YACE,oBAAoB,EAAE,mBAAmB;SAC1C,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AArLW,QAAA,mBAAmB,uBAqL9B;AAMF,MAAM,kBAAkB,GAAG,CAAC,EAC1B,YAAY,EACZ,cAAc,GACK,EAAU,EAAE,CAAC,GAAG,YAAY,KAAK,cAAc,EAAE,CAAC"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleGraphQLObjectType = void 0;
4
4
  const utils_1 = require("../utils");
5
- const handleGraphQLObjectType = ({ fieldFilePath, resolverName, normalizedResolverName, resolversTypeMeta }, { result, config: { graphQLObjectTypeResolversToGenerate } }) => {
5
+ const handleGraphQLObjectType = ({ fieldFilePath, resolverName, normalizedResolverName, resolversTypeMeta, moduleName, }, { result, config: { graphQLObjectTypeResolversToGenerate } }) => {
6
6
  const variableStatement = `export const ${resolverName}: ${resolversTypeMeta.typeString} = {
7
7
  /* Implement ${resolverName} resolver logic here */
8
8
  };`;
@@ -17,6 +17,7 @@ const handleGraphQLObjectType = ({ fieldFilePath, resolverName, normalizedResolv
17
17
  ${variableStatement}`,
18
18
  mainImportIdentifier: resolverName,
19
19
  meta: {
20
+ moduleName,
20
21
  normalizedResolverName,
21
22
  variableStatement,
22
23
  resolversToGenerate: graphQLObjectTypeResolversToGenerate[resolverName], // Array of all resolvers that may need type checking
@@ -1 +1 @@
1
- {"version":3,"file":"handleGraphQLObjectType.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/generateResolverFiles/handleGraphQLObjectType.ts"],"names":[],"mappings":";;;AACA,oCAA2C;AAEpC,MAAM,uBAAuB,GAAuB,CACzD,EAAE,aAAa,EAAE,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,EAC1E,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,oCAAoC,EAAE,EAAE,EAC5D,EAAE;IACF,MAAM,iBAAiB,GAAG,gBAAgB,YAAY,KAAK,iBAAiB,CAAC,UAAU;mBACtE,YAAY;KAC1B,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG;QAC5B,UAAU,EAAE,YAAY;QACxB,OAAO,EAAE;MACP,IAAA,uBAAe,EAAC;YAChB,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,iBAAiB,CAAC,MAAM;YAChC,YAAY,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC;SAClD,CAAC;MACA,iBAAiB,EAAE;QACrB,oBAAoB,EAAE,YAAY;QAClC,IAAI,EAAE;YACJ,sBAAsB;YACtB,iBAAiB;YACjB,mBAAmB,EAAE,oCAAoC,CAAC,YAAY,CAAC,EAAE,qDAAqD;SAC/H;KACF,CAAC;AACJ,CAAC,CAAC;AAxBW,QAAA,uBAAuB,2BAwBlC"}
1
+ {"version":3,"file":"handleGraphQLObjectType.js","sourceRoot":"","sources":["../../../../../packages/typescript-resolver-files/src/generateResolverFiles/handleGraphQLObjectType.ts"],"names":[],"mappings":";;;AACA,oCAA2C;AAEpC,MAAM,uBAAuB,GAAuB,CACzD,EACE,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,GACX,EACD,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,oCAAoC,EAAE,EAAE,EAC5D,EAAE;IACF,MAAM,iBAAiB,GAAG,gBAAgB,YAAY,KAAK,iBAAiB,CAAC,UAAU;mBACtE,YAAY;KAC1B,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG;QAC5B,UAAU,EAAE,YAAY;QACxB,OAAO,EAAE;MACP,IAAA,uBAAe,EAAC;YAChB,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,iBAAiB,CAAC,MAAM;YAChC,YAAY,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC;SAClD,CAAC;MACA,iBAAiB,EAAE;QACrB,oBAAoB,EAAE,YAAY;QAClC,IAAI,EAAE;YACJ,UAAU;YACV,sBAAsB;YACtB,iBAAiB;YACjB,mBAAmB,EAAE,oCAAoC,CAAC,YAAY,CAAC,EAAE,qDAAqD;SAC/H;KACF,CAAC;AACJ,CAAC,CAAC;AA/BW,QAAA,uBAAuB,2BA+BlC"}
@@ -2,8 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleGraphQLRootObjectTypeField = void 0;
4
4
  const utils_1 = require("../utils");
5
- const handleGraphQLRootObjectTypeField = ({ fieldFilePath, resolverName, belongsToRootObject, normalizedResolverName, resolversTypeMeta, }, { result }) => {
6
- const variableStatement = `export const ${resolverName}: NonNullable<${resolversTypeMeta.typeString}> = async (_parent, _arg, _ctx) => { /* Implement ${normalizedResolverName} resolver logic here */ };`;
5
+ const handleGraphQLRootObjectTypeField = ({ fieldFilePath, resolverName, belongsToRootObject, normalizedResolverName, resolversTypeMeta, moduleName, }, { result }) => {
6
+ const suggestion = `/* Implement ${normalizedResolverName} resolver logic here */`;
7
+ let variableStatement = `export const ${resolverName}: NonNullable<${resolversTypeMeta.typeString}> = async (_parent, _arg, _ctx) => { ${suggestion} };`;
8
+ if (belongsToRootObject === 'Subscription') {
9
+ variableStatement = `export const ${resolverName}: NonNullable<${resolversTypeMeta.typeString}> = {
10
+ subscribe: async (_parent, _arg, _ctx) => { ${suggestion} },
11
+ }`;
12
+ }
7
13
  result.files[fieldFilePath] = {
8
14
  __filetype: 'rootObjectTypeFieldResolver',
9
15
  content: `
@@ -15,6 +21,7 @@ const handleGraphQLRootObjectTypeField = ({ fieldFilePath, resolverName, belongs
15
21
  ${variableStatement}`,
16
22
  mainImportIdentifier: resolverName,
17
23
  meta: {
24
+ moduleName,
18
25
  belongsToRootObject,
19
26
  variableStatement,
20
27
  normalizedResolverName,