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
Only generate Exact utility type if documents have operations (dotansimha#10571)
* Remove extraneous test setup
* Do not generate Exact utility type of not used
* Add default test case to check that Exact is used for Mutation and Subscription variables
* Update dev-tests
* Add changeset
* Remove extraneous config for Exact test
Only generate `Exact` utility type at the top if it is used
6
+
7
+
`Exact` utility is only used to wrap variables types for operations (queries, mutations and subscriptions) if they exist in the document. `Exact` is never used when there are _only_ fragments.
8
+
9
+
This is important to conditionally generate as users may use very strict tsconfig that will fail compiling if there are unused types.
@@ -501,7 +502,10 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<
501
502
}
502
503
503
504
getExactUtilityType(): string|null{
504
-
if(!this.config.generatesOperationTypes){
505
+
if(
506
+
!this.config.generatesOperationTypes||// 1. If we don't generate operation types, definitely do not need `Exact`
507
+
!this._needsExactUtilityType// 2. Even if we generate operation types, we may not need `Exact` if there's no operations in the documents i.e. only fragments found
0 commit comments