graphql-tools icon indicating copy to clipboard operation
graphql-tools copied to clipboard

Deterministic (seeded) enum values

Open fkling opened this issue 1 year ago • 0 comments

This is a follow up issue for https://github.com/ardatan/graphql-tools/issues/2272 (where it is suggested to open a new issue).

Is your feature request related to a problem? Please describe.

Some parts of the mock data generation process use their own source of randomness and are difficult to work around. Specifically the generation of enum values.

Describe the solution you'd like

The API could accept a function that returns a random value which is used instead of Math.random(). That would allow the user to make the default behavior deterministic.

Describe alternatives you've considered

Providing custom data generators for every enum type. It's impractical for larger schemas and tedious to account for schema changes. Generators for enum values could themselves be generated with a custom codgen plugin, but that also requires an understanding of the codegen process.

fkling avatar Nov 28 '23 19:11 fkling