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

Usage along with globally exported types #28

Closed RicardoTrindade closed 4 years ago

RicardoTrindade commented 4 years ago

Have a question regarding the usage along with the add plugin https://graphql-code-generator.com/docs/plugins/add

We're using this plugin to have our types globally available, so our generated types file looks like this

declare namespace Api {
  type Payment  = { 
    id: Scalars['Int'];
  }
...
}

When using the generated types we don't need to import them and call Api.Paymentdirectly.

Now when using it with the mock data generator the mocks are generated as follows

export const mockPayment = (overrides?: Partial<Payment>): Payment => {
}

which is not working as the type should have the Api. prefix to compile successfully. Is this something you are considering to support or are accepting a PR any time soon ?

ardeois commented 4 years ago

@RicardoTrindade Yes sure if we can find a way for you to use this plugin, I'm all for it!

I'm accepting pull requests, but I'm not sure how we could support this kind of behaviour. I think of 2 possible solutions:

Ideally if we can find a combination without adding new options that would be great

RicardoTrindade commented 4 years ago

Closing the issue since the PR is closed. Thanks for your help!