{"id":15391400,"url":"https://github.com/mizdra/graphql-codegen-typescript-fabbrica","last_synced_at":"2025-04-12T15:35:37.149Z","repository":{"id":188744499,"uuid":"678090163","full_name":"mizdra/graphql-codegen-typescript-fabbrica","owner":"mizdra","description":"GraphQL Code Generator Plugin to define fake data factory.","archived":false,"fork":false,"pushed_at":"2024-09-19T15:08:54.000Z","size":1875,"stargazers_count":34,"open_issues_count":9,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T12:38:04.844Z","etag":null,"topics":["fake","fake-objects","graphql","graphql-code-generator","testing"],"latest_commit_sha":null,"homepage":"","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/mizdra.png","metadata":{"files":{"readme":"README.md","changelog":null,"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},"funding":{"github":"mizdra"}},"created_at":"2023-08-13T16:40:21.000Z","updated_at":"2025-02-03T02:51:24.000Z","dependencies_parsed_at":"2023-09-24T15:15:13.536Z","dependency_job_id":"bccf9093-7e00-4a32-b061-fd3a1f913a9a","html_url":"https://github.com/mizdra/graphql-codegen-typescript-fabbrica","commit_stats":{"total_commits":219,"total_committers":1,"mean_commits":219.0,"dds":0.0,"last_synced_commit":"67e05c4b7f59a8688f55da8cb41192c95982d9fc"},"previous_names":["mizdra/graphql-fabbrica","mizdra/graphql-codegen-typescript-fabbrica"],"tags_count":9,"template":false,"template_full_name":"mizdra/npm-package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mizdra%2Fgraphql-codegen-typescript-fabbrica","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mizdra%2Fgraphql-codegen-typescript-fabbrica/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mizdra%2Fgraphql-codegen-typescript-fabbrica/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mizdra%2Fgraphql-codegen-typescript-fabbrica/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mizdra","download_url":"https://codeload.github.com/mizdra/graphql-codegen-typescript-fabbrica/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248590145,"owners_count":21129757,"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":["fake","fake-objects","graphql","graphql-code-generator","testing"],"created_at":"2024-10-01T15:11:00.513Z","updated_at":"2025-04-12T15:35:37.118Z","avatar_url":"https://github.com/mizdra.png","language":"TypeScript","funding_links":["https://github.com/sponsors/mizdra"],"categories":[],"sub_categories":[],"readme":"# graphql-codegen-typescript-fabbrica\n\nGraphQL Code Generator Plugin to define mock data factory.\n\n## Installation\n\n```sh\nnpm install -D @mizdra/graphql-codegen-typescript-fabbrica @graphql-codegen/cli @graphql-codegen/typescript\nnpm install -S graphql\n```\n\n## Requirements\n\n- `graphql` \u003e= 16.0.0\n- `typescript` \u003e= 5.0.0\n  - `--moduleResolution Bundler`, `--moduleResolution Node16` or `--moduleResolution NodeNext` is required\n\n## Playground\n\nYou can try this library in the following playground.\n\n- https://stackblitz.com/edit/playground-graphql-codegen-typescript-fabbrica?file=src%2Findex.test.ts\u0026view=editor\n\n## Usage\n\nFirst, you should configure the configuration file of GraphQL Code Generator as follows.\n\n```ts\n// codegen.ts\nimport { CodegenConfig } from '@graphql-codegen/cli';\n\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  generates: {\n    '__generated__/types.ts': {\n      plugins: ['typescript'],\n      config: {\n        enumsAsTypes: true, // required\n        avoidOptionals: true, // required\n        // skipIsAbstractType: false, // If you use Relay, you should set this option to `false`\n      },\n    },\n    './__generated__/fabbrica.ts': {\n      plugins: ['@mizdra/graphql-codegen-typescript-fabbrica'],\n      config: {\n        typesFile: './types', // required\n        // typesFile: './types.js' // If you use factories from Node.js and set `--moduleResolution` of `tsconfig.json` to `Node16` or `NodeNext`, you should add `.js` extension\n      },\n    },\n  },\n};\n\nexport default config;\n```\n\n```graphql\n# schema.graphql\ntype Book {\n  id: ID!\n  title: String!\n  author: Author!\n}\ntype Author {\n  id: ID!\n  name: String!\n  books: [Book!]!\n}\n```\n\nSecond, you should generate the code with the GraphQL Code Generator.\n\n```sh\nnpx graphql-codegen\n```\n\nThen, the utilities to define a factory are generated. You can define your preferred factory with it.\n\n```ts\n// src/app.ts\nimport { defineBookFactory, defineAuthorFactory, dynamic } from '../__generated__/fabbrica';\nimport { faker } from '@faker-js/faker';\n\nconst BookFactory = defineBookFactory({\n  defaultFields: {\n    __typename: 'Book',\n    id: dynamic(({ seq }) =\u003e `Book-${seq}`),\n    title: dynamic(() =\u003e faker.word.noun()),\n    author: undefined,\n  },\n});\nconst AuthorFactory = defineAuthorFactory({\n  defaultFields: {\n    __typename: 'Author',\n    id: dynamic(({ seq }) =\u003e `Author-${seq}`),\n    name: dynamic(() =\u003e faker.person.firstName()),\n    books: undefined,\n  },\n});\n```\n\nThe factory generates strictly typed mock data.\n\n```ts\n// simple\nconst book0 = await BookFactory.build();\nexpect(book0).toStrictEqual({\n  __typename: 'Book',\n  id: 'Book-0',\n  title: expect.any(String),\n  author: undefined,\n});\nexpectTypeOf(book0).toEqualTypeOf\u003c{\n  __typename: 'Book';\n  id: string;\n  title: string;\n  author: undefined;\n}\u003e();\n\n// nested\nconst book1 = await BookFactory.build({\n  author: await AuthorFactory.build(),\n});\nexpect(book1).toStrictEqual({\n  __typename: 'Book',\n  id: 'Book-1',\n  title: expect.any(String),\n  author: {\n    __typename: 'Author',\n    id: 'Author-0',\n    name: expect.any(String),\n    books: undefined,\n  },\n});\nexpectTypeOf(book1).toEqualTypeOf\u003c{\n  __typename: 'Book';\n  id: string;\n  title: string;\n  author: {\n    __typename: 'Author';\n    id: string;\n    name: string;\n    books: undefined;\n  };\n}\u003e();\n```\n\n## Notable features\n\nThe library has several notable features. And many of them are inspired by [FactoryBot](https://thoughtbot.github.io/factory_bot/).\n\n### Dynamic Fields\n\nThe `dynamic` function allows you to define fields with a dynamic value.\n\n```ts\nimport { dynamic } from '../__generated__/fabbrica';\nconst BookFactory = defineBookFactory({\n  defaultFields: {\n    id: dynamic(() =\u003e faker.datatype.uuid()),\n    title: 'Yuyushiki',\n  },\n});\nexpect(await BookFactory.build()).toStrictEqual({\n  id: expect.any(String), // Randomly generated UUID\n  title: 'Yuyushiki',\n});\n```\n\n### Sequences\n\nSequences allow you to build sequentially numbered data.\n\n```ts\nconst BookFactory = defineBookFactory({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Book-${seq}`),\n    title: dynamic(async ({ seq }) =\u003e Promise.resolve(`Yuyushiki Vol.${seq}`)),\n    author: undefined,\n  },\n});\nexpect(await BookFactory.build()).toStrictEqual({\n  id: 'Book-0',\n  title: 'Yuyushiki Vol.0',\n  author: undefined,\n});\nexpect(await BookFactory.build()).toStrictEqual({\n  id: 'Book-1',\n  title: 'Yuyushiki Vol.1',\n  author: undefined,\n});\n```\n\n### Dependent Fields\n\nFields can be based on the values of other fields using `get` function.\n\n```ts\nconst UserFactory = defineUserFactory({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `User-${seq}`),\n    name: 'yukari',\n    email: dynamic(async ({ get }) =\u003e `${(await get('name')) ?? 'defaultName'}@yuyushiki.net`),\n  },\n});\nexpect(await UserFactory.build()).toStrictEqual({\n  id: 'User-0',\n  name: 'yukari',\n  email: 'yukari@yuyushiki.net',\n});\nexpect(await UserFactory.build({ name: 'yui' })).toStrictEqual({\n  id: 'User-1',\n  name: 'yui',\n  email: 'yui@yuyushiki.net',\n});\n```\n\n### Building lists\n\nYou can build a list of mock data with the `buildList` method.\n\n```ts\nconst BookFactory = defineBookFactory({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Book-${seq}`),\n    title: dynamic(({ seq }) =\u003e `Yuyushiki Vol.${seq}`),\n    author: undefined,\n  },\n});\nexpect(await BookFactory.buildList(3)).toStrictEqual([\n  { id: 'Book-0', title: 'Yuyushiki Vol.0', author: undefined },\n  { id: 'Book-1', title: 'Yuyushiki Vol.1', author: undefined },\n  { id: 'Book-2', title: 'Yuyushiki Vol.2', author: undefined },\n]);\n```\n\n### Building connection\n\nYou can build a [connection](https://relay.dev/graphql/connections.htm) of mock data with the `buildConnection` method.\n\n```ts\nconst BookFactory = defineBookFactory({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Book-${seq}`),\n  },\n});\nexpect(await BookFactory.buildConnection(3, { first: 2 })).toStrictEqual([\n  edges: [\n    { cursor: \"YXJyYXljb25uZWN0aW9uOjA=\", node: { id: 'Book-0' } },\n    { cursor: \"YXJyYXljb25uZWN0aW9uOjE=\", node: { id: 'Book-1' } },\n  ],\n  pageInfo: {\n    startCursor: \"YXJyYXljb25uZWN0aW9uOjA=\",\n    endCursor: \"YXJyYXljb25uZWN0aW9uOjE=\",\n    hasPreviousPage: false,\n    hasNextPage: true,\n  },\n]);\n```\n\n### Build mock data of related types (a.k.a. Associations)\n\nYou can build mock data of the relevant type in one shot.\n\n```ts\nconst BookFactory = defineBookFactory({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Book-${seq}`),\n    title: dynamic(({ seq }) =\u003e `Yuyushiki Vol.${seq}`),\n    author: undefined,\n  },\n});\nconst AuthorFactory = defineAuthorFactory({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Author-${seq}`),\n    name: 'Komata Mikami',\n    books: dynamic(async () =\u003e BookFactory.buildList(1)), // Build mock data of related types\n  },\n});\nexpect(await AuthorFactory.build()).toStrictEqual({\n  id: 'Author-0',\n  name: 'Komata Mikami',\n  books: [{ id: 'Book-0', title: 'Yuyushiki Vol.0', author: undefined }],\n});\n```\n\n### Transient Fields\n\nTransient fields are only available within the factory definition and are not included in the data being built. This allows more complex logic to be used inside factories.\n\n```ts\nimport { defineAuthorFactory, dynamic } from '../__generated__/fabbrica';\nimport { Author } from '../__generated__/types';\n\nconst AuthorFactory = defineAuthorFactory.withTransientFields({\n  bookCount: 0,\n})({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Author-${seq}`),\n    name: 'Komata Mikami',\n    books: dynamic(async ({ get }) =\u003e {\n      const bookCount = (await get('bookCount')) ?? 0;\n      return BookFactory.buildList(bookCount);\n    }),\n  },\n});\nexpect(await AuthorFactory.build({ bookCount: 3 })).toStrictEqual({\n  id: 'Author-0',\n  name: 'Komata Mikami',\n  books: [\n    { id: 'Book-0', title: 'Yuyushiki Vol.0', author: undefined },\n    { id: 'Book-1', title: 'Yuyushiki Vol.1', author: undefined },\n    { id: 'Book-2', title: 'Yuyushiki Vol.2', author: undefined },\n  ],\n});\n```\n\n### Additional Fields\n\nYou can add additional fields to the data being built. This is useful when you want to build a fake data for a query that contains [aliases](https://graphql.org/learn/queries/#aliases), such as:\n\n```graphql\nquery GetAuthorInfo {\n  author(id: '1') {\n    id\n    name\n    books {\n      id\n      title\n    }\n    popularBooks: books(popularOnly: true) {\n      id\n      title\n    }\n  }\n}\n```\n\n```ts\nimport { defineAuthorFactory, type OptionalAuthor, dynamic } from '../__generated__/fabbrica';\nconst AuthorFactory = defineAuthorFactory.withAdditionalFields\u003c{ popularBooks: OptionalAuthor['books'] }\u003e()({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Author-${seq}`),\n    name: 'Komata Mikami',\n    // Generate a fake data for the `Author.books()` field\n    books: dynamic(() =\u003e BookFactory.buildList(3)),\n    // Generate a fake data for the `Author.books(popularOnly: true)` field\n    popularBooks: dynamic(() =\u003e BookFactory.buildList(1)),\n  },\n});\nexpect(await AuthorFactory.build()).toStrictEqual({\n  id: 'Author-0',\n  name: 'Komata Mikami',\n  books: [\n    { id: 'Book-0', title: 'Yuyushiki Vol.0' },\n    { id: 'Book-1', title: 'Yuyushiki Vol.1' },\n    { id: 'Book-2', title: 'Yuyushiki Vol.2' },\n  ],\n  popularBooks: [{ id: 'Book-3', title: 'Yuyushiki Vol.3' }],\n});\n```\n\n### Traits\n\nTraits allow you to group the default values of fields and apply them to factories.\n\n```ts\nimport I_SPACER from '../assets/spacer.gif';\nimport I_AVATAR from '../assets/dummy/avatar.png';\nimport I_BANNER from '../assets/dummy/banner.png';\n\nconst ImageFactory = defineImageFactory({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Image-${seq}`),\n    url: I_SPACER.src,\n    width: I_SPACER.width,\n    height: I_SPACER.height,\n  },\n  traits: {\n    avatar: {\n      defaultFields: {\n        url: I_AVATAR.src,\n        width: I_AVATAR.width,\n        height: I_AVATAR.height,\n      },\n    },\n    banner: {\n      defaultFields: {\n        url: I_BANNER.src,\n        width: I_BANNER.width,\n        height: I_BANNER.height,\n      },\n    },\n  },\n});\nexpect(await ImageFactory.build()).toStrictEqual({\n  id: 'Image-0',\n  url: I_SPACER.src,\n  width: I_SPACER.width,\n  height: I_SPACER.height,\n});\nexpect(await ImageFactory.use('avatar').build()).toStrictEqual({\n  id: 'Image-1',\n  url: I_AVATAR.src,\n  width: I_AVATAR.width,\n  height: I_AVATAR.height,\n});\nexpect(await ImageFactory.use('banner').build()).toStrictEqual({\n  id: 'Image-2',\n  url: I_BANNER.src,\n  width: I_BANNER.width,\n  height: I_BANNER.height,\n});\n```\n\n## Available configs\n\nSeveral configs can be set in the GraphQL Code Generator configuration file.\n\n### `typesFile`\n\ntype: `string`, required\n\nDefines the file path containing all GraphQL types. This file can be generated with the [typescript plugin](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript).\n\nIf you use factories on Node.js and set `--moduleResolution` of `tsconfig.json` to `Node16` or `NodeNext`, you should add `.js` extension to the file path. If you use factories on other runtimes, you should not add `.js` extension.\n\n```ts\nimport { CodegenConfig } from '@graphql-codegen/cli';\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  generates: {\n    '__generated__/types.ts': {\n      plugins: ['typescript'],\n      config: {\n        // ...\n      },\n    },\n    './__generated__/fabbrica.ts': {\n      plugins: ['@mizdra/graphql-codegen-typescript-fabbrica'],\n      config: {\n        typesFile: './types', // required\n        // typesFile: './types.js' // If you use factories from Node.js and set `--moduleResolution` of `tsconfig.json` to `Node16` or `NodeNext`, you should add `.js` extension\n      },\n    },\n  },\n};\n```\n\n### `skipTypename`\n\ntype: `boolean`, default: `false`\n\nDoes not add `__typename` to the fields that can be passed to factory.\n\n```ts\nimport { CodegenConfig } from '@graphql-codegen/cli';\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  generates: {\n    '__generated__/types.ts': {\n      plugins: ['typescript'],\n      config: {\n        // ...\n      },\n    },\n    './__generated__/fabbrica.ts': {\n      plugins: ['@mizdra/graphql-codegen-typescript-fabbrica'],\n      config: {\n        // ...\n        skipTypename: true,\n      },\n    },\n  },\n};\nexport default config;\n```\n\n### `skipIsAbstractType`\n\ntype: `boolean`, default: `true`\n\nDoes not add `__is\u003cAbstractType\u003e` to the fields that can be passed to factory. `__is\u003cAbstractType\u003e` is a field that relay-compiler automatically adds to the query[^1][^2]. It is recommended for Relay users to set this option to `false`.\n\n[^1]: https://github.com/facebook/relay/issues/3129#issuecomment-659439154\n\n[^2]: https://github.com/search?q=repo%3Afacebook%2Frelay%20%2F__is%3CAbstractType%3E%2F\u0026type=code\n\n```ts\nimport { CodegenConfig } from '@graphql-codegen/cli';\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  generates: {\n    '__generated__/types.ts': {\n      plugins: ['typescript'],\n      config: {\n        // ...\n      },\n    },\n    './__generated__/fabbrica.ts': {\n      plugins: ['@mizdra/graphql-codegen-typescript-fabbrica'],\n      config: {\n        // ...\n        skipIsAbstractType: false,\n      },\n    },\n  },\n};\nexport default config;\n```\n\n### `nonOptionalDefaultFields`\n\ntype: `boolean`, default: `false`\n\nMake it mandatory to pass all fields to `defaultFields`. This is useful to force the `defaultFields` to be updated when new fields are added to the schema.\n\n```ts\nimport { CodegenConfig } from '@graphql-codegen/cli';\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  generates: {\n    '__generated__/types.ts': {\n      plugins: ['typescript'],\n      config: {\n        // ...\n      },\n    },\n    './__generated__/fabbrica.ts': {\n      plugins: ['@mizdra/graphql-codegen-typescript-fabbrica'],\n      config: {\n        // ...\n        nonOptionalDefaultFields: true,\n      },\n    },\n  },\n};\nexport default config;\n```\n\n### `namingConvention`\n\ntype: `NamingConvention`, default: `change-case-all#pascalCase`\n\nAllow you to override the naming convention of the output.\n\nThis option is compatible with [the one for typescript plugin](https://the-guild.dev/graphql/codegen/docs/config-reference/naming-convention#namingconvention). If you specify it for the typescript plugin, you must set the same value for graphql-codegen-typescript-fabbrica.\n\n```ts\nimport { CodegenConfig } from '@graphql-codegen/cli';\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  config: {\n    namingConvention: 'change-case-all#lowerCase',\n  },\n  generates: {\n    '__generated__/types.ts': {\n      plugins: ['typescript'],\n      // ...\n    },\n    './__generated__/fabbrica.ts': {\n      plugins: ['@mizdra/graphql-codegen-typescript-fabbrica'],\n      // ...\n    },\n  },\n};\nexport default config;\n```\n\n### `typesPrefix`\n\ntype: `string`, default: `''`\n\nPrefixes all the generated types.\n\nThis option is compatible with [the one for typescript plugin](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript#typesprefix). If you specify it for the typescript plugin, you must set the same value for graphql-codegen-typescript-fabbrica.\n\n```ts\nimport { CodegenConfig } from '@graphql-codegen/cli';\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  config: {\n    typesPrefix: 'I',\n  },\n  generates: {\n    '__generated__/types.ts': {\n      plugins: ['typescript'],\n      // ...\n    },\n    './__generated__/fabbrica.ts': {\n      plugins: ['@mizdra/graphql-codegen-typescript-fabbrica'],\n      // ...\n    },\n  },\n};\nexport default config;\n```\n\n### `typesSuffix`\n\ntype: `string`, default: `''`\n\nSuffixes all the generated types.\n\nThis option is compatible with [the one for typescript plugin](https://the-guild.dev/graphql/codegen/plugins/typescript/typescript#typessuffix). If you specify it for the typescript plugin, you must set the same value for graphql-codegen-typescript-fabbrica.\n\n## Troubleshooting\n\n### `error TS7022: '\u003cType\u003eFactory' implicitly has type 'any' because ...`\n\nCreating a circular type with [Associations](#build-mock-data-of-related-types-aka-associations) may cause compile errors.\n\n```ts\nconst BookFactory = defineBookFactory({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Book-${seq}`),\n    title: dynamic(({ seq }) =\u003e `ゆゆ式 ${seq}巻`),\n    author: dynamic(({ seq }) =\u003e AuthorFactory.build()),\n  },\n});\nconst AuthorFactory = defineAuthorFactory({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Author-${seq}`),\n    name: dynamic(({ seq }) =\u003e `${seq}上小又`),\n    books: dynamic(({ seq }) =\u003e BookFactory.buildList()),\n  },\n});\n```\n\n```console\n$ npx tsc --noEmit\nexample.ts:1:7 - error TS7022: 'BookFactory' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.\n\n1     const BookFactory = defineBookFactory({\n            ~~~~~~~~~~~\n\nexample.ts:8:7 - error TS7022: 'AuthorFactory' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.\n\n8     const AuthorFactory = defineAuthorFactory({\n            ~~~~~~~~~~~~~\n```\n\nThis error is due to the type of each field being cycled, making the type undecidable. To avoid this, you can pass `undefined` to any field.\n\n```ts\nconst BookFactory = defineBookFactory({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Book-${seq}`),\n    title: dynamic(({ seq }) =\u003e `ゆゆ式 ${seq}巻`),\n    author: dynamic(({ seq }) =\u003e AuthorFactory.build()),\n  },\n});\nconst AuthorFactory = defineAuthorFactory({\n  defaultFields: {\n    id: dynamic(({ seq }) =\u003e `Author-${seq}`),\n    name: dynamic(({ seq }) =\u003e `${seq}上小又`),\n    // Pass `undefined` to avoid type being undecidable.\n    books: undefined,\n  },\n});\n```\n\n### `error TS2307: Cannot find module '@mizdra/graphql-codegen-typescript-fabbrica/helper' or its corresponding type declarations.`\n\nIncorrect values for the `moduleResolution` option in `tsconfig.json` cause compile errors.\n\n```json\n{\n  \"compilerOptions\": {\n    \"moduleResolution\": \"node\" // incorrect\n  }\n}\n```\n\n```console\n$ npx tsc --noEmit\n__generated__/1-basic/fabbrica.ts:7:8 - error TS2307: Cannot find module '@mizdra/graphql-codegen-typescript-fabbrica/helper' or its corresponding type declarations.\n\n7 } from '@mizdra/graphql-codegen-typescript-fabbrica/helper';\n         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n```\n\nTo resolve this error, set the value of `moduleResolution` to `Bundler`, `Node16` or `NodeNext`.\n\n```json\n{\n  \"compilerOptions\": {\n    \"moduleResolution\": \"Bundler\" // ok\n  }\n}\n```\n\n## License\n\nThis library is licensed under the MIT license.\n\nThe copyright contains two names. The first is [@mizdra](https://github.com/mizdra), author of graphql-codegen-typescript-fabbrica. The second is [@Quramy](https://github.com/Quramy), author of [prisma-fabbrica](https://github.com/Quramy/prisma-fabbrica).\n\nThe name of the author of prisma-fabbrica is written because graphql-codegen-typescript-fabbrica reuses some of prisma-fabbrica's code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmizdra%2Fgraphql-codegen-typescript-fabbrica","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmizdra%2Fgraphql-codegen-typescript-fabbrica","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmizdra%2Fgraphql-codegen-typescript-fabbrica/lists"}