{"id":17085460,"url":"https://github.com/zhouzi/graphql-codegen-factories","last_synced_at":"2025-07-09T15:36:32.420Z","repository":{"id":37100370,"uuid":"275177910","full_name":"zhouzi/graphql-codegen-factories","owner":"zhouzi","description":"Generate factories from a GraphQL schema and operations to mock data.","archived":false,"fork":false,"pushed_at":"2024-03-03T09:24:34.000Z","size":2219,"stargazers_count":29,"open_issues_count":13,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-15T10:15:35.967Z","etag":null,"topics":["factories","graphql","graphql-codegen","mocking","plugin","testing"],"latest_commit_sha":null,"homepage":"https://gabinaureche.com/graphql-codegen-factories/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhouzi.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":"contributing.md","funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-26T14:40:38.000Z","updated_at":"2024-04-16T05:42:10.000Z","dependencies_parsed_at":"2024-03-03T10:40:41.622Z","dependency_job_id":null,"html_url":"https://github.com/zhouzi/graphql-codegen-factories","commit_stats":{"total_commits":102,"total_committers":5,"mean_commits":20.4,"dds":0.08823529411764708,"last_synced_commit":"3f049bc030401dd8b08e3da31a37a0d9bf10bef4"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/zhouzi/graphql-codegen-factories","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouzi%2Fgraphql-codegen-factories","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouzi%2Fgraphql-codegen-factories/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouzi%2Fgraphql-codegen-factories/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouzi%2Fgraphql-codegen-factories/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhouzi","download_url":"https://codeload.github.com/zhouzi/graphql-codegen-factories/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouzi%2Fgraphql-codegen-factories/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264486533,"owners_count":23616070,"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":["factories","graphql","graphql-codegen","mocking","plugin","testing"],"created_at":"2024-10-14T13:24:43.396Z","updated_at":"2025-07-09T15:36:32.055Z","avatar_url":"https://github.com/zhouzi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphql-codegen-factories\n\n![](https://img.shields.io/github/license/zhouzi/graphql-codegen-factories?style=for-the-badge) ![](https://img.shields.io/github/actions/workflow/status/zhouzi/graphql-codegen-factories/.github/workflows/ci.yml?branch=main\u0026style=for-the-badge) ![](https://img.shields.io/npm/v/graphql-codegen-factories?style=for-the-badge)\n\n`graphql-codegen-factories` is a plugin for [GraphQL Code Generator](https://www.graphql-code-generator.com/) that generates factories from a GraphQL schema and operations.\nThe factories can then be used to mock data, e.g for testing or seeding a database.\n\nFor example, given this GraphQL schema:\n\n```graphql\ntype User {\n  id: ID!\n  username: String!\n}\n```\n\nThe following factory will be generated:\n\n```typescript\nexport type User = /* generated by @graphql-codegen/typescript */;\n\nexport function createUserMock(props: Partial\u003cUser\u003e = {}): User {\n  return {\n    __typename: \"User\",\n    id: \"\",\n    username: \"\",\n    ...props,\n  };\n}\n```\n\nIt is also possible to generate factories from an operation, for example:\n\n```graphql\nquery GetUser {\n  user {\n    id\n    username\n  }\n}\n```\n\nWill result in the following factories:\n\n```typescript\nexport type GetUserQuery = /* generated by @graphql-codegen/typescript-operations */;\n\nexport function createGetUserQueryMock(props: Partial\u003cGetUserQuery\u003e = {}): GetUserQuery {\n  return {\n    __typename: \"Query\",\n    user: createGetUserQueryMock_user({}),\n    ...props,\n  };\n}\n\nexport function createGetUserQueryMock_user(props: Partial\u003cGetUserQuery[\"user\"]\u003e = {}): GetUserQuery[\"user\"] {\n  return {\n    __typename: \"User\",\n    id: \"\",\n    username: \"\",\n    ...props,\n  };\n}\n```\n\nYou can also use a fake data generator to generate realistic factories such as:\n\n```typescript\nimport { faker } from \"@faker-js/faker\";\n\nexport function createUserMock(props: Partial\u003cUser\u003e = {}): User {\n  return {\n    __typename: \"User\",\n    id: faker.random.alphaNumeric(16),\n    username: faker.lorem.word(),\n    ...props,\n  };\n}\n```\n\n- [Documentation](https://gabinaureche.com/graphql-codegen-factories/)\n- [Examples](https://github.com/zhouzi/graphql-codegen-factories/tree/main/examples)\n  - [Minimal](https://stackblitz.com/github/zhouzi/graphql-codegen-factories/tree/main/examples/minimal)\n  - [Usage with near-operation-file-preset](https://stackblitz.com/github/zhouzi/graphql-codegen-factories/tree/main/examples/usage-with-near-operation-file-preset)\n  - [Usage with faker](https://stackblitz.com/github/zhouzi/graphql-codegen-factories/tree/main/examples/usage-with-faker)\n\n## Showcase\n\n- [yummy-recipes/yummy](https://github.com/yummy-recipes/yummy)\n\nAre you using this plugin? [Let us know!](https://github.com/zhouzi/graphql-codegen-factories/issues/new)\n\n## Contributors\n\n[![](https://github.com/zhouzi.png?size=50)](https://github.com/zhouzi)\n[![](https://github.com/ertrzyiks.png?size=50)](https://github.com/ertrzyiks)\n[![](https://github.com/jongbelegen.png?size=50)](https://github.com/jongbelegen)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhouzi%2Fgraphql-codegen-factories","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhouzi%2Fgraphql-codegen-factories","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhouzi%2Fgraphql-codegen-factories/lists"}