{"id":47817,"library":"graphql-codegen-factories","title":"GraphQL Codegen Factories","description":"A plugin for GraphQL Code Generator that automatically creates factory functions for your GraphQL types. Version 1.2.1 (stable) generates factories for all types defined in your schema, enabling easy test data creation with default values. Differentiates from similar tools by tight integration with graphql-codegen and zero-config setup. Released under MIT license.","status":"active","version":"1.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/zhouzi/graphql-codegen-factories","tags":["javascript","graphql","graphql-codegen","plugin","factories"],"install":[{"cmd":"npm install graphql-codegen-factories","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-codegen-factories","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-codegen-factories","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for codegen runtime","package":"graphql","optional":false}],"imports":[{"note":"Factories are generated into your project, not imported from the package.","wrong":"import { UserFactory } from '@graphql-codegen/factories'","symbol":"factory function","correct":"import { UserFactory } from './generated/factories'"},{"note":"ESM only; no default export.","wrong":"const FactoryConfig = require('graphql-codegen-factories')","symbol":"config","correct":"import { FactoryConfig } from 'graphql-codegen-factories'"},{"note":"Default export is the plugin function.","wrong":"import { factories } from 'graphql-codegen-factories'","symbol":"plugin","correct":"import factoriesPlugin from 'graphql-codegen-factories'"}],"quickstart":{"code":"// codegen.yml\nschema: './schema.graphql'\ngenerates:\n  ./generated/factories.ts:\n    plugins:\n      - graphql-codegen-factories\nexec: npx graphql-codegen\n\n// Use factory\nimport { UserFactory } from './generated/factories';\nconst user = UserFactory.build({ name: 'Alice' });","lang":"typescript","description":"Configure GraphQL Code Generator to use the factories plugin and generate factory functions from your schema. Then use them in tests to create data with custom overrides."},"warnings":[{"fix":"Manually specify enum fields when calling build() or wrap factory to provide defaults","message":"Generated factories do not include enum values from schema; enum fields are left undefined unless explicitly provided in build()","severity":"gotcha","affected_versions":"1.0.0 - 1.2.1"},{"fix":"Ensure your project supports ESM or TypeScript, or pin to 1.1.x","message":"In v1.2.0, the generated output format changed from JavaScript to TypeScript, breaking CommonJS require() imports","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Move inline types to a .graphql schema file","message":"The plugin no longer supports inline type definitions; types must be defined in a separate schema file","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Remove 'mocks' from codegen.yml and use 'factories' if you had custom mock settings","message":"The 'mocks' option has been removed; use 'factories' instead for all configurations","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.2.1':20 'automat':11 'code':8 'codegen':2,49,63 'config':53 'creat':12 'creation':35 'data':34 'default':37 'defin':27 'differenti':39 'easi':32 'enabl':31 'factori':3,13,23,65 'function':14 'generat':9,22 'graphql':1,7,17,48,60,62 'graphql-codegen':47,61 'integr':45 'javascript':59 'licens':58 'mit':57 'plugin':5,64 'releas':55 'schema':30 'setup':54 'similar':41 'stabl':21 'test':33 'tight':44 'tool':42 'type':18,26 'valu':38 'version':19 'zero':52 'zero-config':51","created_at":"2026-06-07T16:53:28.044560+00:00","updated_at":"2026-06-07T16:53:28.044560+00:00","problems":[{"fix":"Run: npm install graphql-codegen-factories --save-dev","cause":"Package not installed or path incorrect","error":"Error: Cannot find module 'graphql-codegen-factories'"},{"fix":"Use: import factoriesPlugin from 'graphql-codegen-factories'","cause":"Incorrect import: using named import instead of default","error":"TypeError: factories is not a function"},{"fix":"Check file path and extension in codegen.yml","cause":"Schema file not found or path wrong","error":"Failed to load schema from ./schema.graphql"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/zhouzi/graphql-codegen-factories#readme","github":"https://github.com/zhouzi/graphql-codegen-factories","docs":null,"changelog":null,"pypi":null,"npm":"graphql-codegen-factories","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}