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

Mocks do not respect aliases #149

Closed davidgtu closed 7 months ago

davidgtu commented 7 months ago

I have an query that uses aliases like so:

 ... on AttributeBoolean {
          booleanValue: value
        }
        ... on AttributeDate {
          dateValue: value
        }
        ... on AttributeDatetime {
          datetimeValue: value
        }
        ... on AttributeFloat {
          floatValue: value
        }
        ... on AttributeInteger {
          integerValue: value
        }
        ... on AttributeString {
          stringValue: value
        }

However, when I generate my mock data, it seems to retain value rather than booleanValue etc.

My config currently looks like this:

generates:
  ./src/generated/generated-mock.ts:
    plugins:
      - typescript-mock-data:
          typesFile: ./graphql.ts
          typeNames: pascal-case#pascalCase
          useImplementingTypes: true
          scalars:
            AWSTimestamp: unix_time # gets translated to casual.unix_time
deiga commented 3 months ago

@davidgtu How did you resolve this? I'm facing a similar issue

danielvanmil commented 1 week ago

+1 having the same issue?

ardeois commented 1 week ago

As far as I understand the ... on AttributeBoolean syntax is for queries and not schema definition.

This plugin currently doesn't generate operation for queries, but only for schemas

See here