-
Notifications
You must be signed in to change notification settings - Fork 54
feat: add includedTypes and excludedTypes options for selective mock generation #179
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
Conversation
# Conflicts: # tests/typescript-mock-data.spec.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea seems fine, thanks for your contribution !
I have one concern about non-types definitions that we should probably support.
Also, if a type uses other types, should we automatically include them? Or should we leave that decision to the user ?
Hmm we can include that but it will increase the complexity for now IMO. For now that lets keep it like that, if there will be a problem (And also I will use it :) ), if it is getting a problem in the future we can do that. But for now we do not need imo. |
I agree it would indeed increase the complexity, so let's keep it like that. So just add allow the non-types definitions and add snapshots please |
|
This looks amazing! Will be very beneficial for us since the amount of generated mocks in our application really slows things down (IDE, Typescript etc). Is there anything I can help with to get this out soon? 😄 |
|
This would be helpful for us too until the |
This PR introduces two new configuration options,
includedTypesandexcludedTypes, to thegraphql-codegen-typescript-mock-dataplugin for enhanced control over mock data generation:Changes Introduced:
includedTypes(Array of strings):includedTypeswill have mock data generated.excludedTypes(Array of strings):excludedTypeswill not have mock data generated.Precedence:
includedTypesandexcludedTypesare provided,includedTypestakes precedence overexcludedTypes.Examples:
1.
includedTypesExample:In this configuration, mock data will be generated only for
UserandAvatartypes.2.
excludedTypesExample:In this configuration,
UserandAvatartypes will be excluded from mock data generation.3. Combined
includedTypesandexcludedTypes:In this example, despite being listed in
excludedTypes,Userwill still have mock data generated becauseincludedTypestakes precedence.Documentation Updates:
includedTypesandexcludedTypesin the README.md.Tests:
includedTypesandexcludedTypes:This update provides flexibility for users to selectively include or exclude types, making mock data generation more efficient and tailored to specific testing needs.