-
Notifications
You must be signed in to change notification settings - Fork 52
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,
includedTypes
andexcludedTypes
, to thegraphql-codegen-typescript-mock-data
plugin for enhanced control over mock data generation:Changes Introduced:
includedTypes
(Array of strings):includedTypes
will have mock data generated.excludedTypes
(Array of strings):excludedTypes
will not have mock data generated.Precedence:
includedTypes
andexcludedTypes
are provided,includedTypes
takes precedence overexcludedTypes
.Examples:
1.
includedTypes
Example:In this configuration, mock data will be generated only for
User
andAvatar
types.2.
excludedTypes
Example:In this configuration,
User
andAvatar
types will be excluded from mock data generation.3. Combined
includedTypes
andexcludedTypes
:In this example, despite being listed in
excludedTypes
,User
will still have mock data generated becauseincludedTypes
takes precedence.Documentation Updates:
includedTypes
andexcludedTypes
in the README.md.Tests:
includedTypes
andexcludedTypes
:This update provides flexibility for users to selectively include or exclude types, making mock data generation more efficient and tailored to specific testing needs.