graphql-code-generator 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
graphql-code-generator 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
graphql-code-generator 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 MIT License
开发语言 Java
操作系统 跨平台
软件类型 开源软件
所属分类 大数据数据查询
地区 不详
投 递 者 首席测试
适用人群 未知
收录时间 2021-11-23



npm version CircleCI Discord Chat code style: prettier renovate-app badge

GraphQL Codegen 1.0 is here!

GraphQL Code Generator is a tool that generates code out of your GraphQL schema. Whether you are developing a frontend or backend, you can utilize GraphQL Code Generator to generate output from your GraphQL Schema and GraphQL Documents (query/mutation/subscription/fragment).

By analyzing the schema and documents and parsing it, GraphQL Code Generator can output code at a wide variety of formats, based on pre-defined templates or based on custom user-defined ones. Regardless of the language that you're using, GraphQL Code Generator got you covered.

GraphQL Code Generator lets you choose the output that you need, based on plugins, which are very flexible and customizable. You can also write your plugins to generate custom outputs that match your needs.

You can try this tool live on your browser and see some useful examples. Check out GraphQL Code Generator Live Examples.

We currently support and maintain these plugins (TypeScript, Flow, React, Angular, MongoDB, Stencil, Reason, and some more), and there is an active community that writes and maintains custom plugins.

Quick Start

Start by installing the basic deps of GraphQL Codegen;

yarn add graphql
yarn add -D @graphql-codegen/cli

GraphQL Code Generator lets you setup everything by simply running the following command:

yarn graphql-codegen init

Question by question, it will guide you through the whole process of setting up a schema, selecting plugins, picking a destination of a generated file, and a lot more.

If you don't want to use the wizard, install it by yourself and create a basic codegen.yml configuration file, point to your schema, and pick the plugins you wish to use.

Install CLI using yarn:

yarn add -D @graphql-codegen/cli

And create a config like below:

schema: http://localhost:3000/graphql
      - typescript

Then, run the code-generator using graphql-codegen command:

yarn graphql-codegen

The command above may fetch (for example) the following GraphQL schema:

type Author {
  id: Int!
  firstName: String!
  lastName: String!
  posts(findTitle: String): [Post]

type Post {
  id: Int!
  title: String!
  author: Author!

type Query {
  posts: [Post]

schema {
  query: Query

And generate the following TypeScript typings:

export type Maybe<T> = T | null;

/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
  ID: string,
  String: string,
  Boolean: boolean,
  Int: number,
  Float: number,

export type Author = {
  __typename?: 'Author',
  id: Scalars['Int'],
  firstName: Scalars['String'],
  lastName: Scalars['String'],
  posts?: Maybe<Array<Maybe<Post>>>,

export type AuthorPostsArgs = {
  findTitle?: Maybe<Scalars['String']>

export type Post = {
  __typename?: 'Post',
  id: Scalars['Int'],
  title: Scalars['String'],
  author: Author,

export type Query = {
  __typename?: 'Query',
  posts?: Maybe<Array<Maybe<Post>>>,


Besides our docs page, feel free to go through our published Medium articles to get a better grasp of what GraphQL Code Generator is all about:


If this is your first time contributing to this project, please do read our Contributor Workflow Guide before you get started off.

Feel free to open issues and pull requests. We're always welcome support from the community.

For a contribution guide specific to this project, please refer to:

Code of Conduct

Help us keep GraphQL Codegenerator open and inclusive. Please read and follow our Code of Conduct as adopted from Contributor Covenant


GitHub license





点击引领话题📣 发布并加入讨论🔥
{{o.pubDate | formatDate}}


{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
{{o.pubDate | formatDate}}


{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
Mermaid 输入验证错误漏洞
Mermaid是一个应用软件。使用文本和代码创建图表和可视化。 Mermaid 8.13.8之前版本存在输入验证错误漏洞,攻击者可利用该漏洞通过恶意图表在阅读图表的机器上运行javascript代码。
CVE-2021-43861 MPS-2021-36986
2022-08-08 19:10
Moment.js 正则拒绝服务漏洞
Moment.js 是一个 JavaScript 日期库。用于解析、验证、操作和格式化日期。 Moment.js 在处理嵌套 rfc2822 注释内容时正则表达式执行时间不断的指数增大,导致服务不可用。 攻击者可利用该漏洞使目标服务停止响应甚至崩溃。
CVE-2022-31129 MPS-2022-11159
2022-08-08 19:10
undici < 5.7.1 存在CRLF序列注入漏洞
undici是一个HTTP/1.1客户端。在小于5.7.1的undici版本中,可以将 CRLF序列注入到 undici 中的请求标头中,从而引起http请求拆分漏洞。
CVE-2022-31150 MPS-2022-11180
2022-08-08 19:10
0 评论
0 收藏