{"id":13772749,"url":"https://github.com/danieljharvey/graphql-codegen-fast-check","last_synced_at":"2025-05-11T05:33:34.326Z","repository":{"id":42283426,"uuid":"252104816","full_name":"danieljharvey/graphql-codegen-fast-check","owner":"danieljharvey","description":"Generate Fastcheck arbitraries from GraphQL Schema","archived":false,"fork":false,"pushed_at":"2023-01-05T18:12:55.000Z","size":1497,"stargazers_count":22,"open_issues_count":11,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-06T22:33:58.419Z","etag":null,"topics":["fast-check","graphql","graphql-codegen","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danieljharvey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-01T07:36:11.000Z","updated_at":"2023-01-22T06:22:41.000Z","dependencies_parsed_at":"2023-02-04T09:45:35.829Z","dependency_job_id":null,"html_url":"https://github.com/danieljharvey/graphql-codegen-fast-check","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieljharvey%2Fgraphql-codegen-fast-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieljharvey%2Fgraphql-codegen-fast-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieljharvey%2Fgraphql-codegen-fast-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieljharvey%2Fgraphql-codegen-fast-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danieljharvey","download_url":"https://codeload.github.com/danieljharvey/graphql-codegen-fast-check/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253523690,"owners_count":21921815,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fast-check","graphql","graphql-codegen","typescript"],"created_at":"2024-08-03T17:01:07.466Z","updated_at":"2025-05-11T05:33:33.885Z","avatar_url":"https://github.com/danieljharvey.png","language":"TypeScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# GraphQL Codegen for Fast Check\n\n## What?\n\n[GraphQL Code Generator](https://graphql-code-generator.com/) lets you generate\ncode from a `GraphQL` schema. It is commonly used to create `Typescript`\ntypes to ensure the consuming program agrees with the data it is receiving.\n\n[Fast-check](https://github.com/dubzzz/fast-check) is a Property Testing\nframework for `Typescript` / `Javascript`. It allows testing properties of a\nprogram using arbitrarily generated data. `Fast-check` uses `arbitrary`s to\ncreate data, that is, descriptions of the data we need to create.\n\nSay we have this datatype...\n\n```typescript\n// our datatype\ninterface Person {\n  name: string;\n  age: number;\n}\n```\n\n...the code to make the `fast-check` `arbitrary` would look like:\n\n```typescript\nimport * as fc from \"fast-check\";\n\nconst personArbitrary = fc.record({\n  name: fc.string(),\n  age: fc.integer()\n});\n```\n\nThis can then be used in property tests or as generators to create sample test\ndata. The problem is that writing them all by hand and keeping them up to date\nwith your datatypes is a pain.\n\n## This library\n\nThis library is a plugin for `GraphQL Code Generator` that creates `fast-check`\n`Arbitrary`s for your schema data types.\n\n## How to use\n\nAdd the library to your project (and GraphQL Codegen if you need it):\n\n```bash\nyarn add graphql-codegen-fast-check @graphql-codegen/cli\n```\n\nCreate a `codegen.yml` file.\n\n```yaml\nschema: path-to-my-graphql-schema.graphql\ngenerates:\n  output.ts:\n    - graphql-codegen-fast-check\n```\n\nThen run the generator in the same folder as your `codegen.yml` file:\n\n```bash\nyarn graphql-codegen\n```\n\n(hopefully) Success! You should have an `output.ts` folder full of `arbitrary`s\nyou can use in your project.\n\n## What's working?\n\n- [x] Object types\n- [x] Built-in Scalar types\n- [x] Enumeration types\n- [x] Type modifiers (1)\n- [ ] Custom Scalar types (2)\n- [x] Union types\n- [x] Interface types (3)\n- [ ] Input types (4)\n- [ ] Documents (5)\n\n1.  Currently lists work but we ignore the nullable / non-nullable distinction.\n    Everything is non-nullable for now, this will come soon.\n2.  Custom Scalar types are defined outside the schema, frustratingly. For now\n    they all emit a `string`, the plan is to allow the config to specify a file\n    to override these with the user's own `arbitrary` instances.\n3.  These \"work\" but need to check whether they are actually correct\n4.  Currently these just output a `string` (why? don't know) - `fast-check` has\n    a `func` `arbitrary` which should make this fairly straightforward to\n    implement.\n5.  I haven't even thought about tackling this part yet.\n\n## Other notes\n\nRecursive declarations will utterly explode if you try and use them. I have a\nplan to implement a limit to stop this.\n\n## Inspiration\n\nThanks to [fast-check-io-ts](https://www.npmjs.com/package/fast-check-io-ts)\nfor showing me that making `arbitrary` instances should be easy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieljharvey%2Fgraphql-codegen-fast-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanieljharvey%2Fgraphql-codegen-fast-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieljharvey%2Fgraphql-codegen-fast-check/lists"}