New option onlyOperationTypes
for typescript and flow
#3760
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a new config option
onlyOperationTypes
intended to generate only types for operations (enums, scalars, etc..., #3475 (comment) may be related)Non-operation types are incorrect to use for the client-side. You can't get a value of the type if you don't have an operation for that. But since non-operation types are not marked, my coworkers accidentally using them all the time. That option will get rid of that
When using
preResolveTypes
you probably don't need all base types, so now you can skip them and significantly reduce the size of types file. For example, indev-test/star-wars
384 lines dropped to 183 withpreResolveTypes
+onlyOperationTypes
dev-test/star-wars/types.ts
dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts
I think probably
onlyOperationTypes
+preResolveTypes
should be default for client-side types on the next major release. It makes types smaller and avoids incorrect usage.