当前位置: 首页 > 软件库 > 大数据 > 数据查询 >

graphql-code-generator

授权协议 MIT License
开发语言 Java
所属分类 大数据、 数据查询
软件类型 开源软件
地区 不详
投 递 者 乌鸿宝
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

CodeGen

graphql-code-generator.com

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
generates:
  ./src/types.d.ts:
    plugins:
      - 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>>>,
};

Links

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:

Contributing

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: http://graphql-code-generator.com/docs/custom-codegen/contributing

Code of Conduct

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

License

MIT

  • 使用DataLoader 使用GraphQL的过程中,可能需要在一个图数据上做多次查询。使用原始的数据加载方式,很容易产生性能问题。 通过使用java-dataloader,可以结合缓存(Cache)和批处理(Batching)的方式,在图形数据上发起批量请求。如果dataloader已经获取过相关的数据,那么它会缓存数据的值,然后直接返回给调用方(无需重复发起请求)。 假设我们有一个StarWa

  • <dependency> <groupId>com.graphql-java</groupId> <artifactId>graphql-java</artifactId> <version>17.3</version> </dependency> https://www.graphql-java.com/documentation/schema Getting s

  • java graphql by Prithviraj Pawar 通过Prithviraj Pawar 如何立即启动GraphQL Java服务器并使其运行 (How to get your GraphQL Java server up and running in no time) GraphQL is a query language for fetching data over the in

  • 翻译:疯狂的技术宅 blog.logrocket.com/build-a-gra… 声明:未经允许,严禁转载 近一两年来 GraphQL 和 TypeScript 的使用都程爆发式增长,当两者与React结合使用时,它们可以为开发人员提供理想的开发体验。 GraphQL 改变了我们对 API 的思考方式,并利用直观的键/值对匹配,客户端可以请求在网页或移动应用屏幕上显示所需的确切数据。 TypeS

 相关资料
  • code-generator 是一款可以自己按需定制的代码生成工具,根据你的业务场景,定制模板,可以减少你50%的重复工作。 适用场景:springmvc mybatis mysql 使用说明: 1.找到generate.xml文件,修改相应标签元素:如t_incallring <!-- 需要根据实际情况改动的部分  开始--><!-- commonspackage 包命名路径,开发中需要根据具体

  • Code Runner for VS Code支持了超过 30 种语言: C, C++, Java, JavaScript, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F# Script, C# Script, VBScript, TypeScript, CoffeeScript, Scala,

  • Bootstrap允许您使用两种不同的键方式显示代码 - 第一个是code标签。 如果要以内联方式显示代码,则应使用code标记。 第二个是pre标签。 如果代码需要显示为独立的块元素,或者如果它有多行,那么您应该使用pre标记。 确保在使用pre和code标记时,使用unicode变体作为开始和结束标记 - &lt; 和&gt; 。 我们来看下面的例子 - <p><code><header></

  • 快速开始 GraphQL 是一种用于 API 的查询语言。这是 GraphQL 和 REST 之间一个很好的比较 (译者注: GraphQL 替代 REST 是必然趋势)。在这组文章中, 我们不会解释什幺是 GraphQL, 而是演示如何使用 @nestjs/GraphQL 模块。 GraphQLModule 只不过是 Apollo 服务器的包装器。我们没有造轮子, 而是提供一个现成的模块, 这让

  • GraphQL 既是一种用于 API 的查询语言也是一个满足你数据查询的运行时。 GraphQL 对你的 API 中的数据提供了一套易于理解的完整描述,使得客户端能够准确地获得它需要的数据,而且没有任何冗余,也让 API 更容易地随着时间推移而演进,还能用于构建强大的开发者工具。 向你的 API 发出一个 GraphQL 请求就能准确获得你想要的数据,不多不少。 GraphQL 查询总是返回可预测

  • 一个自带GUI基于freemarker模板的代码生成器 最新版本:下载 v0.1.1 通过读取数据库表结构,根据提供的模板生成代码,如java MVC各层增删查改代码、前端数据维护页面代码、Mybatis的mapper.xml映射文件,等等。 可扩展支持其他数据库或其他数据结构源。已支持的数据库包括: MySQL MsSql(SQLServer) Oracle SybaseASE15 HsqlDb