@adgstudio/graphql-generator 中文文档教程

发布于 3年前 浏览 5 项目主页 更新于 3年前

Graphql Generator

生成 graphql 对象、类型定义和合并 sdl 从

Install

从 graphql sdl/s从 npm 安装

npm install -D @adgstudio/graphql-generator

Usage

Generate Graphql Types

graphql sdl 文件生成graphql 打字稿类型 从 graphql sdl 文件

import { GraphqlTypesGenerator } from "@adgstudio/graphql-generator";

async function main() {
  const generator = new GraphqlTypesGenerator();
  await factory.generate("./src/**/*.graphql", {
    outputPath: "path/to/destination.ts",
  });
}

main();

Generate Graphql Object

生成 graphql 对象定义 将

import { GraphqlObjectGenerator } from "@adgstudio/graphql-generator";

async function main() {
  const generator = new GraphqlObjectGenerator();
  await generator.generate("./src/modules/**/*.graphql", {
    outputPath: "path/to/destination.ts",
  });
}

main();

Merge graphql sdl to a single file

多个 graphql sdl 文件合并到一个 graphql sdl 文件

import { GraphqlSdlFactory } from "@adgstudio/graphql-generator";

async function main() {
  const generator = new GraphqlSdlFactory();
  await generator.merge("./src/modules/**/*.graphql", {
    outputPath: "path/to/destination.graphql",
  });
}

main();

Contributing

Fork this repo 并创建 pull向 dev 分支发出

Support

请求abdulghani0">youtube。

Graphql Generator

Generate graphql object, type definition and merge sdl from graphql sdl/s

Install

install from npm

npm install -D @adgstudio/graphql-generator

Usage

Generate Graphql Types

Generate graphql typescript types from graphql sdl file

import { GraphqlTypesGenerator } from "@adgstudio/graphql-generator";

async function main() {
  const generator = new GraphqlTypesGenerator();
  await factory.generate("./src/**/*.graphql", {
    outputPath: "path/to/destination.ts",
  });
}

main();

Generate Graphql Object

Generate graphql object definition from graphql sdl file

import { GraphqlObjectGenerator } from "@adgstudio/graphql-generator";

async function main() {
  const generator = new GraphqlObjectGenerator();
  await generator.generate("./src/modules/**/*.graphql", {
    outputPath: "path/to/destination.ts",
  });
}

main();

Merge graphql sdl to a single file

Merge multiple graphql sdl files to a single graphql sdl file

import { GraphqlSdlFactory } from "@adgstudio/graphql-generator";

async function main() {
  const generator = new GraphqlSdlFactory();
  await generator.merge("./src/modules/**/*.graphql", {
    outputPath: "path/to/destination.graphql",
  });
}

main();

Contributing

Fork this repo and create pull request to dev branch

Support

Follow twitter, and youtube.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文