{"id":18930094,"url":"https://github.com/labd/graphql-codegen-faker-fixtures","last_synced_at":"2025-04-15T15:31:16.765Z","repository":{"id":180911934,"uuid":"665047550","full_name":"labd/graphql-codegen-faker-fixtures","owner":"labd","description":"Generate Faker fixtures for your GraphQL Fragments using GraphQL codegen","archived":false,"fork":false,"pushed_at":"2024-02-01T00:59:45.000Z","size":581,"stargazers_count":4,"open_issues_count":6,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T22:51:12.760Z","etag":null,"topics":["codegen","fakerjs","fixtures","graphql"],"latest_commit_sha":null,"homepage":"","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/labd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2023-07-11T10:14:43.000Z","updated_at":"2024-08-13T08:56:25.000Z","dependencies_parsed_at":"2024-11-08T11:51:50.254Z","dependency_job_id":null,"html_url":"https://github.com/labd/graphql-codegen-faker-fixtures","commit_stats":null,"previous_names":["labd/graphql-codegen-faker-fixtures"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fgraphql-codegen-faker-fixtures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fgraphql-codegen-faker-fixtures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fgraphql-codegen-faker-fixtures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fgraphql-codegen-faker-fixtures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/labd","download_url":"https://codeload.github.com/labd/graphql-codegen-faker-fixtures/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249097902,"owners_count":21212372,"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":["codegen","fakerjs","fixtures","graphql"],"created_at":"2024-11-08T11:36:30.419Z","updated_at":"2025-04-15T15:31:16.319Z","avatar_url":"https://github.com/labd.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphql-codegen-faker-fixtures\n\nThis repository contains a GraphQL Codegen plugin that generates fixture builders of your fragments based on your GraphQL schema and populates them with [faker](https://github.com/faker-js/faker).\n\n## Installation\n\nRun either of the following commands to add the package and it's dependencies, based on your package manager of choice:\n\n```sh\n# pnpm\npnpm i -D graphql-codegen-faker-fixtures @faker-js/faker deepmerge-ts\n\n# npm\nnpm i --save-dev graphql-codegen-faker-fixtures @faker-js/faker deepmerge-ts\n\n# yarn\nyarn add -D graphql-codegen-faker-fixtures @faker-js/faker deepmerge-ts\n```\n\n## Usage\n\n### Config file\n\nBoth `codegen.yml` and `codegen.ts` config files are permitted. It is recommended to use the typescript format which includes a config interface.\n\n```typescript\nimport type { CodegenConfig } from \"graphql-codegen-faker-fixtures\";\n\nconst config: CodegenConfig = {\n  verbose: true,\n  schema: \"example/schema.graphql\",\n  documents: \"example/queries.ts\",\n  generates: {\n    \"example/fixture_builders.ts\": {\n      plugins: [\"graphql-codegen-faker-fixtures\"],\n      config: {\n        typeImport: \"@types\",\n        fakerjsSeed: 98765,\n        scalars: {\n          Email: {\n            _default: \"faker.internet.email()\",\n            secondaryEmail: \"faker.internet.exampleEmail()\",\n          },\n          String: {\n            _default: \"faker.lorem.word()\",\n            firstName: \"faker.person.firstName()\",\n            lastName: \"faker.person.lastName()\",\n            phone: \"faker.phone.number()\",\n          },\n          Boolean: { married: \"faker.helpers.arrayElement(['yes', 'no'])\" },\n          ID: {\n            id: \"faker.string.symbol()\",\n            [\"Person.id\"]: \"faker.string.nanoid()\",\n          },\n        },\n      },\n    },\n  },\n  hooks: {\n    afterOneFileWrite: [\"prettier --write\"],\n  },\n};\n\nexport default config;\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eExample in \u003ccode\u003eyml\u003c/code\u003e format\u003c/summary\u003e\n\n```yml\nschema: example/schema.graphql\ndocuments: example/queries.ts\nverbose: true\ngenerates:\n  example/fixture_builders.ts:\n    plugins:\n      - graphql-codegen-faker-fixtures\n    config:\n      typeImport: \"@types\"\n      fakerjsSeed: 98765\n      scalars:\n        Email:\n          _default: faker.internet.email()\n          secondaryEmail: faker.internet.exampleEmail()\n        String:\n          _default: faker.lorem.word()\n          firstName: faker.person.firstName()\n          lastName: faker.person.lastName()\n          phone: faker.phone.number()\n        Boolean:\n          married: faker.helpers.arrayElement(['yes', 'no'])\n        ID:\n          id: faker.string.symbol()\n          Person.id: faker.string.nanoid()\nhooks:\n  afterOneFileWrite:\n    - prettier --write\n```\n\n\u003c/details\u003e\n\nThe example above and a copy in `yml` format can be found in the /examle directory and can be run with `pnpm example:ts` and `pnpm example:yml` respectively.\n\n### API\n\nThe config object includes the following fields:\n\n#### `buildersOnly` (`boolean`)\n\nWhen true the plugin will only return the fixture builder functions without the normal addition of a disclaimer, utility functions (`repeat`, `deepmerge` \u0026 `random`), utilty type (`DeepPartial`), and faker seed setup.\n\n#### `fakerjsSeed` (`number`)\n\ndefault value: `12345654321`\n\nNumber used to seed faker.\n[Reference](https://fakerjs.dev/guide/usage.html#reproducible-results)\n\n#### `namingConvention` (`\"keep\" | \"change-case-all#\u003ccase-type\u003e\"`)\n\ndefault value: `change-case-all#pascalCase`\n\nsupported `\u003ccase-type\u003e` options: `camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase`\n\nNaming convention used in fixture builder generation.\n[Reference](https://github.com/btxtiger/change-case-all)\n\n#### `scalars` (`ScalarConfig`)\n\nOverride default faker methods for a given scalar type. The default methods and configured scalar are:\n\n| Scalar        | Default faker method       |\n| ------------- | -------------------------- |\n| `Int`         | `faker.number.int()`       |\n| `Float`       | `faker.number.float()`     |\n| `Boolean`     | `faker.datatype.boolean()` |\n| `ID`          | `faker.string.uuid()`      |\n| `String`      | `faker.lorem.words()`      |\n| custom scalar | `faker.lorem.words()`      |\n\nOverriding a faker methods:\n\n```typescript\nscalars: {\n    String: {\n        // Override the default method for the String scalar\n        _default: \"faker.lorem.word()\"\n        // Provide a faker method for a specific field name for the String scalar\n        firstName: \"faker.person.firstName()\"\n    },\n    ID: {\n        // Provide a faker method for a specific field name and type for the ID scalar\n        [\"Person.id\"]: \"faker.string.nanoid()\",\n    }\n}\n```\n\n#### `skipFields` (`string[]`)\n\nSkip the given fields while generating the fixture builders. The notation is as follows:\n\n```typescript\nskipFields: ['PersonFragment.email'],\n```\n\n#### `skipFragments` (`string[]`)\n\nSkip the given fragments while generating the fixture builders. The notation is as follows:\n\n```typescript\nskipFragments: ['person'],\n```\n\n#### `typeImport` (`string`)\n\nImport types generated from your fragments based on your GraphQL schema. These types provide typing of the fixture builder functions.\n\n## Development\n\nAssuming you have `pnpm` installed with `node@18`, run:\n\n```sh\npnpm install\npnpm start\n```\n\n## Publishing\n\nPublishing is done automatically via merging a changesets release pull request to main.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabd%2Fgraphql-codegen-faker-fixtures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flabd%2Fgraphql-codegen-faker-fixtures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabd%2Fgraphql-codegen-faker-fixtures/lists"}