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
133 stars 47 forks source link

Rename JSONFilter and UUIDFilter to JsonFilter and UuidFilter #66

Closed naknode closed 2 years ago

naknode commented 2 years ago

This plugin is great except for the fact that I have to rename JSONFilter and UUIDFilter to JsonFilter and UuidFilter everywhere after every codegen.

Is there a way to bypass this or does an MR need to be submitted?

Here is my build_local_types.yml:

  mocks/generated-local-mocks.ts: ## Generate a local mocked data generator
    plugins:
      - typescript-mock-data:
          typesFile: '../src/types/types.ts'
          enumValues: keep
          terminateCircularRelationships: true
          skipTypename: true
          typenames: keep
          prefix: 'mock'
          scalars:
            Date: date
            Datetime: date
ardeois commented 2 years ago

@naknode can you provide an example of how your generate typescript types too? I see you use typenames: keep and enumValues: keep, that's probably why the name is not updated Have you tried updating typenames with values in the doc?

https://github.com/ardeois/graphql-codegen-typescript-mock-data#typenames-string-defaultvalue-pascal-casepascalcase

ardeois commented 2 years ago

@naknode did you see my last comment? Otherwise, I will close this issue if it's inactive for too long

naknode commented 2 years ago

@ardeois Thank you. This is what i needed. I understand. My import statement is now this: import UuidFilter...

However, it's still wrong on this generate code:

    name:
      overrides && overrides.hasOwnProperty('name')
        ? overrides.name!
        : relationshipsToOmit.has('StringFilter')
        ? ({} as StringFilter)
        : mockStringFilter({}, relationshipsToOmit),
    attributes:
      overrides && overrides.hasOwnProperty('attributes')
        ? overrides.attributes!
        : relationshipsToOmit.has('JSONFilter')
        ? ({} as JSONFilter)
        : mockJsonFilter({}, relationshipsToOmit),

As you can see, it still says as JSONFilter when it should say as JsonFilter like at the top.

ardeois commented 2 years ago

@naknode can you try again with latest version? It should be fixed in version 2.1.2

naknode commented 2 years ago

@naknode can you try again with latest version? It should be fixed in version 2.1.2

I believe you. I'll try again when I come back to work. :-)