You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously, Object types from the schema were generated via the `typescript` plugin, for example:
215
215
@@ -230,11 +230,11 @@ Now, Object types are no longer generated. This prevents accidental misuse of sc
230
230
231
231
If you need schema types for any reason, please generate them using the `typescript` plugin in a separate file.
232
232
233
-
2. Args types are no longer generated
233
+
### 2. Args types are no longer generated
234
234
235
235
Args types are only used for server use cases, so they are no longer generated for client use cases.
236
236
237
-
3. Scalar types are no longer generated as a reusable type
237
+
### 3. Scalar types are no longer generated as a reusable type
238
238
239
239
Previously, Scalar types from the schema were generated into an object and reused in Variables types:
240
240
@@ -271,13 +271,13 @@ export type UserVariables = Exact<{
271
271
}>
272
272
```
273
273
274
-
4. Input and Enum types are only generated when used
274
+
### 4. Input and Enum types are only generated when used
275
275
276
276
Previously, all Input and Enum types were generated, even if they were not used. This could increase bundle size when Enums that incur runtime cost (e.g. native TypeScript enum or const enum) are used.
277
277
278
278
Now, only Input and Enum types used in operations are generated.
279
279
280
-
5. `__typename` is only generated when used
280
+
### 5. `__typename` is only generated when used
281
281
282
282
Previously, `__typename` fields in Result types are generated as optional by default, even when they were not requested:
283
283
@@ -317,7 +317,7 @@ export type UserQuery = {
317
317
continue to use `skipTypeNameForRoot` and `nonOptionalTypename` options to configure expected type behaviours.
318
318
</Callout>
319
319
320
-
6. Document field types are generated to correctly match runtime expectations
320
+
### 6. Document field types are generated to correctly match runtime expectations
321
321
322
322
Previously, nullable fields in Result types were generated as optional by default:
323
323
@@ -340,7 +340,7 @@ export type UserQuery = {
340
340
}
341
341
```
342
342
343
-
7. Enum config options are consolidated and the default value is changed
343
+
### 7. Enum config options are consolidated and the default value is changed
344
344
345
345
Previously, there were 4 boolean options to set which Enum variant to generate. When combined, these options overrode one another, leading to unexpected and confusing behaviour.
346
346
@@ -354,7 +354,7 @@ Now, `enumType` is the only config option to use. The default has also been chan
8. `avoidOptionals` option is updated to only handle Operation types
357
+
### 8. `avoidOptionals` option is updated to only handle Operation types
358
358
359
359
Previously, `avoidOptionals` was shared with the [typescript plugin](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript#avoidoptionals). As a result, some inner options did not affect Operation types (such as `avoidOptionals.resolvers`, `avoidOptionals.query`, `avoidOptionals.mutation`, `avoidOptionals.subscription`).
360
360
@@ -366,7 +366,7 @@ Now, there are only 3 inner options, and when enabled, each forces the respectiv
366
366
367
367
Note that the default is `false`, and you can still use `avoidOptionals:true` to turn on all options, without having to set each one individually.
368
368
369
-
9. `preResolveTypes` option is removed
369
+
### 9. `preResolveTypes` option is removed
370
370
371
371
The `preResolveTypes` option was used to generate Result types inline (`preResolveTypes:false`) or use the ones generated by the `typescript` plugin (`preResolveTypes:true`). This approach had several drawbacks:
372
372
@@ -378,21 +378,21 @@ The `preResolveTypes` option was used to generate Result types inline (`preResol
378
378
379
379
If you are seeing problems, please create an issue [here](https://github.com/dotansimha/graphql-code-generator/issues).
380
380
381
-
10. Legacy utility types are removed
381
+
### 10. Legacy utility types are removed
382
382
383
383
The following utility types have been removed:
384
384
385
385
- `Maybe`: used to handle nullability types of fields in Result types. However, field types have been pre-resolved and inlined for a long time, so this type is no longer needed.
386
386
- `InputMaybe`: used to handle nullability types of Input. Input types are now inlined, so this type is no longer needed.
387
387
- `MakeOptional`, `MakeMaybe` and `MakeEmpty`: used to handle `preResolveTypes:false`. However, `preResolveTypes` has been removed, so these types are no longer needed.
388
388
389
-
11. Make `unknown` the default type for custom scalars instead of `any`
389
+
### 11. Make `unknown` the default type for custom scalars instead of `any`
390
390
391
391
Previously, the default custom Scalars type was `any`, which bypassed typechecking.
392
392
393
393
Now, the default type is `unknown` to ensure data is handled carefully by users.
394
394
395
-
12. Make `string|number` the default type for the native `ID` scalar
395
+
### 12. Make `string|number` the default type for the native `ID` scalar
396
396
397
397
Previously, one set of default Scalar types was shared between client and server plugins via the `typescript` plugin dependency. This meant it was not possible to set the default for client, as it would complicate the server config, and vice versa. See this [PR for more details](https://github.com/dotansimha/graphql-code-generator/pull/9497).
0 commit comments