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
// Don't add 'Query'/'Mutation'/'Subscription' suffixes to operation result types
276
294
omitOperationSuffix: true,
277
295
// Don't add 'Fragment' suffix to fragment result types
278
-
fragmentSuffix: ''
296
+
fragmentSuffix: '',
297
+
generatesOperationTypes: true,
298
+
// Default is 'unknown'; to match Apollo tooling we need to put 'any'
299
+
defaultScalarType: 'any'
279
300
}
280
301
}
281
302
}
@@ -288,13 +309,50 @@ export default config
288
309
289
310
The setup above closely mimics Apollo Tooling but isn’t an exact match. The following items may require manual fixes:
290
311
291
-
1. Nested field types naming. In very rare cases, the names generated by GraphQL Codegen don’t match Apollo Tooling’s. Update these cases manually.
312
+
1. Nested field types naming.
313
+
314
+
In very rare cases, the names generated by GraphQL Codegen don’t match Apollo Tooling’s. Update these cases manually.
315
+
316
+
2. Enum file location.
292
317
293
-
2. Enum file location. Occasionally, GraphQL Codegen places enums in a different file. If an enum is missing, check nearby generated files and adjust your imports accordingly.
318
+
Occasionally, GraphQL Codegen places enums in a different file then Apollo Tooling. If an enum is missing, check nearby generated files and adjust your imports accordingly.
294
319
295
-
3. Occasional mismatch between `Type | null` and `Type | null | undefined`.
320
+
3.`is possibly null` and `has any type` typecheck bugs.
321
+
322
+
These bugs has to be fixed.
323
+
324
+
For `is possibly null` bug, asserting for not null or adding `!` will fix most cases:
325
+
326
+
```
327
+
getUser.name -> getUser!.name
328
+
```
296
329
297
-
4. Occasional `is possibly null` and `has any type` typecheck bugs.
330
+
For `has any type` bug - a proper type needs to be determined.
331
+
332
+
4. Mismatch between `Type | null` and `Type | null | undefined`.
333
+
334
+
Experiment with the following configuration options to keep your codebase changes to a minimum:
335
+
336
+
```
337
+
maybeValue: defaults to 'T | null', set to 'T | null | undefined' if necessary
338
+
inputMaybeValue: defaults to 'Maybe<T>', set to 'T | null | undefined' if necessary
339
+
avoidOptionals: Replaces ? optional modifier with explicit Maybe<T>. Supports granular control via object form.
optionalResolveType: Makes __resolveType optional (__resolveType?) in resolver types.
342
+
nullability: When errorHandlingClient: true, adjusts nullability for fields marked with @semanticNonNull directive (requires graphql-sock).
343
+
```
344
+
345
+
5. Extra `__typename` present, or required `__typename` missing.
346
+
347
+
Experiment with the following configuration options to keep your codebase changes to a minimum:
348
+
349
+
```
350
+
skipTypename: prevents adding __typename to generated types unless explicitly in the selection set.
351
+
skipTypeNameForRoot: skips __typename specifically for root types (Query, Mutation, Subscription). Ignored if __typename is explicitly in the selection set
352
+
nonOptionalTypename: always adds __typename and makes it a required (non-optional) field.
353
+
addTypenameToSelectionSets: injects __typename directly into the generated document node selection sets.
354
+
resolversNonOptionalTypename: makes __typename non-optional in resolver mappings without affecting base types. Supports granular control via object form.
0 commit comments