@fruits-chain/graphql-codegen-preset

0.3.5 • Public • Published

GraphQL Codegen Preset

24jieqi 团队 graphql-codegen 通用方案

lerna

使用方式

## graphql-codegen
yarn add @fruits-chain/graphql-codegen-preset --dev

## graphql 相关
yarn add @apollo/client graphql

package.json 中添加 scripts

{
  "gen:graphql-codegen": "fruits-chain-gc http://192.168.10.233:9406/graphql",
  "gen:graphql-codegen:w": "fruits-chain-gc http://192.168.10.233:9406/graphql -w"
}

参数

--watch

fruits-chain-gc http://xx/graphql -w 或 fruits-chain-gc http://xx/graphql --watch

监听代码变更自动生成代码

--ignore-eslint

fruits-chain-gc http://xx/graphql -ie 或 fruits-chain-gc http://xx/graphql --ignore-eslint

生成代码后自动 eslint,默认不做 eslint,如果需要命令为 fruits-chain-gc http://xx/graphql --no-ignore-eslint

--folder

fruits-chain-gc http://xx/graphql -f gg 或 fruits-chain-gc http://xx/graphql --folder gg

自定义 graphql 文件夹,默认值 src/graphql

--schema

fruits-chain-gc http://xx/graphql -s gg 或 fruits-chain-gc http://xx/graphql --schema gg

自定义 schema.graphql 文件夹,默认值 generated,文件保存路径:${F}/${S}/schema.graphql

--types

fruits-chain-gc http://xx/graphql -t tt 或 fruits-chain-gc http://xx/graphql --types tt

自定义 types.ts 文件夹,默认值 generated,文件保存路径:${F}/${T}/types.ts

--documents

fruits-chain-gc http://xx/graphql -d gqls 或 fruits-chain-gc http://xx/graphql --documents gqls

自定义 .gql 文件夹,默认值 operations,文件保存路径:${F}/${D}/**/**.gql

--scalars

fruits-chain-gc http://xx/graphql --scalars BigDecimal:number ID:string

自定义 GraphQL 类型转换

--schema-ast-f

fruits-chain-gc http://xx/graphql -saf 或 fruits-chain-gc http://xx/graphql --schema-ast-f

使用 @fruits-chain/schema-ast 插件,GraphQL 接口必须有一个 _service 的接口返回全量 schema 字符串。

Readme

Keywords

Package Sidebar

Install

npm i @fruits-chain/graphql-codegen-preset

Weekly Downloads

11

Version

0.3.5

License

ISC

Unpacked Size

9.89 kB

Total Files

4

Last publish

Collaborators

  • hemuxue
  • nietao
  • changhuali
  • never-w
  • limoer
  • winljm001
  • onlyling