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

feat: add `scalars` config option for custom GraphQL [scalar -> casual] mappings #21

Closed 3nvi closed 4 years ago

3nvi commented 4 years ago

Background

Some apps use custom scalar for date-related stuff. This caused issues with the way graphql-codegen-typescript-mock-data handles autogenerated data, since a "random string" (the current default), may not always be what you need.

This PR allows you to define mapping from your custom scalars to a casual embedded generator, allowing you to specify exactly how your scalar's autogenerated value will be populated

Closes #20

Caveats

To make configuration simple, a few "shortcuts" were taken. Namely:

3nvi commented 4 years ago

There is a minorr issue with stringification that tests didn't catch. Will update the PR.

Update: Done