graphql-codegen-typescript-mock-data icon indicating copy to clipboard operation
graphql-codegen-typescript-mock-data copied to clipboard

Enum field names don't get resolved the same as codegen typescript plugin by default

Open farmstrong8 opened this issue 2 years ago • 5 comments

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

farmstrong8 avatar Jun 13 '22 17:06 farmstrong8

Thanks for reporting this, I'll try to take a look to this next week

ardeois avatar Jun 28 '22 18:06 ardeois

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.

stale[bot] avatar Jul 28 '22 19:07 stale[bot]

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.

stale[bot] avatar Aug 30 '22 19:08 stale[bot]

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.

stale[bot] avatar Oct 12 '22 18:10 stale[bot]

bump

alxhghs avatar Oct 12 '22 20:10 alxhghs

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

ardeois avatar Oct 31 '22 15:10 ardeois

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

ardeois avatar Dec 05 '22 22:12 ardeois