{"id":47818,"library":"graphql-codegen-core","title":"GraphQL Code Generator Core","description":"Core package for GraphQL Code Generator (v0.18.2), a tool that generates TypeScript/Flow types, React hooks, and other code from GraphQL schemas and operations. Stable release; moderate release cadence. Differentiator: plugin-based architecture supporting multiple frameworks (Apollo, URQL, etc.) and languages, with customizable outputs for resolvers, client-side operations, and introspection. Compared to alternatives (e.g., Apollo CLI), it offers broader plugin ecosystem and plugin-specific granularity.","status":"active","version":"0.18.2","language":"javascript","source_language":"en","source_url":"https://github.com/dotansimha/graphql-codegen","tags":["javascript","gql","generator","code","types","interfaces","graphql","codegen","apollo","typescript"],"install":[{"cmd":"npm install graphql-codegen-core","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-codegen-core","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-codegen-core","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: required at runtime for schema and document processing.","package":"graphql","optional":false}],"imports":[{"note":"ESM default import is typical; CJS require works but may cause issues with dynamic imports in plugins.","wrong":"const generate = require('graphql-codegen-core');","symbol":"generate","correct":"import { generate } from 'graphql-codegen-core';"},{"note":"TypeScript type: exported as named export, not default.","wrong":"import CodegenContext from 'graphql-codegen-core';","symbol":"CodegenContext","correct":"import { CodegenContext } from 'graphql-codegen-core';"},{"note":"Types namespace is a named export; don't use deep imports.","wrong":"import { Types } from 'graphql-codegen-core/src/types';","symbol":"Types","correct":"import { Types } from 'graphql-codegen-core';"}],"quickstart":{"code":"import { generate } from 'graphql-codegen-core';\nimport { buildSchema } from 'graphql';\n\nconst schema = buildSchema(`\n  type Query {\n    hello: String\n  }\n`);\nconst docs = [];\n\nasync function main() {\n  const output = await generate({\n    schema: schema,\n    documents: docs,\n    filename: 'types.ts',\n    plugins: [\n      {\n        'typescript': {}\n      }\n    ],\n    pluginMap: {\n      'typescript': await import('@graphql-codegen/typescript')\n    }\n  });\n  console.log(output[0].content);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Generates TypeScript types from a GraphQL schema using the typescript plugin."},"warnings":[{"fix":"Use `generate({ schema, documents, filename, plugins, pluginMap })` instead of `generate(schema, documents, plugins)`.","message":"v0.18 changed the generate function signature: now takes a single config object instead of multiple arguments.","severity":"breaking","affected_versions":">=0.18.0"},{"fix":"Use ES module import syntax: `import { generate } from 'graphql-codegen-core'`.","message":"The `require('graphql-codegen-core')` CJS import is discouraged; ESM is preferred and will be required in future releases.","severity":"deprecated","affected_versions":">=0.18.0"},{"fix":"Always pass a `pluginMap` object with resolved plugin modules (e.g., `{typescript: await import('@graphql-codegen/typescript')}`).","message":"Plugin map must be explicitly provided; plugins from `@graphql-codegen/*` are not auto-loaded.","severity":"gotcha","affected_versions":">=0.10.0"},{"fix":"Always include `filename` in the config object; it is now mandatory.","message":"In v0.16, the `generate` function required `filename` property, but in v0.15 it was optional.","severity":"breaking","affected_versions":">=0.16.0"}],"env_vars":null,"search_vec":"'altern':59 'apollo':41,61,81 'architectur':37 'base':36 'broader':65 'cadenc':32 'cli':62 'client':52 'client-sid':51 'code':2,9,22,76 'codegen':80 'compar':57 'core':4,5 'customiz':47 'differenti':33 'e.g':60 'ecosystem':67 'etc':43 'framework':40 'generat':3,10,15,75 'gql':74 'granular':72 'graphql':1,8,24,79 'hook':19 'interfac':78 'introspect':56 'javascript':73 'languag':45 'moder':30 'multipl':39 'offer':64 'oper':27,54 'output':48 'packag':6 'plugin':35,66,70 'plugin-bas':34 'plugin-specif':69 'react':18 'releas':29,31 'resolv':50 'schema':25 'side':53 'specif':71 'stabl':28 'support':38 'tool':13 'type':17,77 'typescript':82 'typescript/flow':16 'urql':42 'v0.18.2':11","created_at":"2026-06-07T16:53:28.052709+00:00","updated_at":"2026-06-07T16:53:28.052709+00:00","problems":[{"fix":"Install the plugin: `npm install -D @graphql-codegen/typescript`","cause":"Missing dependency for the plugin.","error":"Cannot find module '@graphql-codegen/typescript'"},{"fix":"Ensure schema is built with `buildSchema` or from an introspection result. Example: `buildSchema(fs.readFileSync('schema.graphql', 'utf8'))`","cause":"Passing invalid schema type (e.g., undefined, or an object without introspection).","error":"Error: Schema must be a `GraphQLSchema` object or a string."},{"fix":"Provide a valid string to `filename` in the generate config object.","cause":"`filename` property is not a string or is missing.","error":"Error: The \"path\" argument must be of type string."}],"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/dotansimha/graphql-codegen#readme","github":"https://github.com/dotansimha/graphql-codegen","docs":null,"changelog":null,"pypi":null,"npm":"graphql-codegen-core","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","database"],"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}}