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
134 stars 46 forks source link

Naming convention for typenames is non-configurable and default is not consistent with the default of the typescript plugin #16

Closed mdazy closed 4 years ago

mdazy commented 4 years ago

The hardcoded behavior for typenames appears to be to retain the casing, whereas the default for the typescript plugin is to use pascalCase. As a result, there is a mismatch between the types generated by the two plugins: a type name such as ETPObject yields EtpObject with typescriptand ETPObject with typescript-mock-data.

Fortunately the typescript plugin allows to change the naming convention for typenames, so this can be worked around like this:

generates:
  ./schema/lib/clientTypes.tsx:
    plugins:
      - typescript
    config:
      namingConvention:
        typeNames: keep # for compatibility with typescript-mock-data

However, this means I need to adjust my existing code because hooks such as useGetEtpObjects have become useGetETPObjects.

It would be good to have matching default behaviors and maybe also matching configuration options.

Thanks.

mdazy commented 4 years ago

I'm going to try and propose a PR for this. See #18

ardeois commented 4 years ago

Fixed in version 0.4.0 Thanks for the PR @mdazy !