Skip to content

New option onlyOperationTypes for typescript and flow #3760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2020

Conversation

standy
Copy link
Contributor

@standy standy commented Mar 31, 2020

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, in dev-test/star-wars 384 lines dropped to 183 with preResolveTypes + 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.

@standy
Copy link
Contributor Author

standy commented Apr 20, 2020

@dotansimha please could you take a look on this MR.
I really want this feature for all my projects. Any advice and suggestions will be greatly appreciated

@dotansimha
Copy link
Owner

@standy Sorry for the delay, I will look into it soon :)

@dotansimha
Copy link
Owner

This is awesome, thank you so much @standy .
I agree with you, in the next version we are probably change the default behaviour to that.

@dotansimha dotansimha force-pushed the only-operation-types branch from 167fad8 to dd94b4e Compare April 28, 2020 11:14
@dotansimha dotansimha merged commit 9332267 into dotansimha:master Apr 28, 2020
@havenchyk
Copy link
Contributor

amazing guys, thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants