ardeois / graphql-codegen-typescript-mock-data

[GraphQL Codegen Plugin](https://github.com/dotansimha/graphql-code-generator) for building mock data based on the schema.
MIT License
132 stars 47 forks source link

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

Closed farmstrong8 closed 1 year ago

farmstrong8 commented 2 years ago

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
ardeois commented 2 years ago

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

stale[bot] commented 1 year ago

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] commented 1 year ago

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] commented 1 year ago

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.

alxhghs commented 1 year ago

bump

ardeois commented 1 year ago

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 commented 1 year ago

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