ardatan / ardatan/graphql-tools
Deterministic (seeded) enum values
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 830
- Avg merge
- 10h 59m
- Merged PRs (30d)
- 45
Description
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.
Contributor guide
Research direction
The issue names no files, tests, or entry points; start by locating enum value generation in the mock data generation path and inspect how randomness is sourced. Done means the API can accept a caller-provided random-value function for enum generation, with deterministic behavior demonstrated by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100