graphql-codegen-typescript-mock-data
graphql-codegen-typescript-mock-data copied to clipboard
Enum field names don't get resolved the same as codegen typescript plugin by default
There is a naming mismatch when generating the mock data. For example if you have this enum, it gets resolved as:
// Enum
export enum Sort {
createdDate = "createdDate",
_id = "_id",
}
// codegen typescript
export enum Sort {
Id = '_id',
CreatedDate = 'createdDate'
}
when Id is referenced in the mock data it gets called using ._Id instead of .Id
...
return {
...
sortBy: overrides && overrides.hasOwnProperty('sortBy') ? overrides.sortBy! : Sort._Id,
};
codegen.yml
generates:
./src/generated-gql.ts:
plugins:
- typescript
- typescript-operations
- typescript-react-apollo
- typescript-resolvers
- typescript-apollo-client-helpers
- fragment-matcher
./tests/mocks/generated-mocks.ts:
plugins:
- typescript-mock-data
config:
typesFile: "../../src/generated-gql.ts"
terminateCircularRelationships: true
Thanks for reporting this, I'll try to take a look to this next week
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
bump
Hello ! Sorry for the delay I didn't have time to work on this project lately. I have a very busy week, but I'll try to work on various issues in PR in November
Sorry for the very late reply @alxhghs but I was finally able to spend some time on this project.
I do reproduce your issue, I'll try to open a PR soon