作用

  • 代码生成

  • schema 处理

  • 脚手架应用创建

  • 项目管理

安装cli

npm install -g graphql-cli

初始化项目(使用.graphqlconfig管理)

以下为demo

  • demo 项目创建
graphql init
  • 添加数据操作(一般名称为database)

使用prisma cli

prisma init database
  • 添加database 项目
graphql add-project database
  • 修改配置

.graphqlconfig.yaml


projects:
demo:
schemaPath: schema.graphql
extensions:
endpoints:
default: 'http://localhost:4466'
database:
schemaPath: src/generated/prisma.graphql
extensions:
prisma: database/prisma.yml
  • 生成schema
graphql get-schema --project database

  • 代码生成

    • 生成typescript typings

    .graphqlconfig.yaml


    projects:
    demo:
    schemaPath: src/schema.graphql
    extensions:
    endpoints:
    default: 'http://localhost:4466'
    codegen:
    generator: typegen
    language: typescript
    input: "{binding,prisma}/*.ts"
    output:
    typings: src/typings.ts
    database:
    schemaPath: src/generated/prisma.graphql
    extensions:
    prisma: database/prisma.yml graphql codegen
    • 生成type 定义

    修改配置

    projects:
    demo:
    schemaPath: src/schema.graphql
    extensions:
    endpoints:
    default: 'http://localhost:4466'
    codegen:
    generator: prisma-binding
    language: typescript
    output:
    binding: src/prisma.ts
    database:
    schemaPath: src/generated/prisma.graphql
    extensions:
    prisma: database/prisma.yml graphql codegen
    • binding

    修改配置

    install binding:
    npm install -g graphql-binding projects:
    demo:
    schemaPath: src/schema.graphql
    extensions:
    endpoints:
    default: 'http://localhost:4466'
    codegen:
    - generator: graphql-binding
    language: typescript
    input: schema.js
    output:
    binding: mybinding.ts
    database:
    schemaPath: src/generated/prisma.graphql
    extensions:
    prisma: database/prisma.yml graphql codegen
 
 
 
 

graphql cli 开发graphql api flow的更多相关文章

  1. 使用ASP.NET Core开发GraphQL服务器 -- 预备知识(上)

    为了介绍使用ASP.NET Core构建GraphQL服务器,本文需要介绍一下GraphQL,其实看官网的文档就行. 什么是GraphQL? GraphQL 既是一种用于 API 的查询语言也是一个满 ...

  2. 【视频】使用ASP.NET Core开发GraphQL服务

    GraphQL 既是一种用于 API 的查询语言也是一个满足你数据查询的运行时. GraphQL来自Facebook,它于2012年开始开发,2015年开源. GraphQL与编程语言无关,可以使用很 ...

  3. ASP.NET Core Web API 开发-RESTful API实现

    ASP.NET Core Web API 开发-RESTful API实现 REST 介绍: 符合REST设计风格的Web API称为RESTful API. 具象状态传输(英文:Representa ...

  4. [GraphQL] Write a GraphQL Schema in JavaScript

    Writing out a GraphQL Schema in the common GraphQL Language can work for simple GraphQL Schemas, but ...

  5. [GraphQL] Serve a GraphQL Schema as Middleware in Express

    If we have a GraphQL Schema expressed in terms of JavaScript, then we have a convenient package avai ...

  6. [GraphQL] Create a GraphQL Schema

    we’ll take a look at the GraphQL Language and write out our first GraphQL Schema. We’ll use the grap ...

  7. flask开发restful api系列(8)-再谈项目结构

    上一章,我们讲到,怎么用蓝图建造一个好的项目,今天我们继续深入.上一章中,我们所有的接口都写在view.py中,如果几十个,还稍微好管理一点,假如上百个,上千个,怎么找?所有接口堆在一起就显得杂乱无章 ...

  8. flask开发restful api

    flask开发restful api 如果有几个原因可以让你爱上flask这个极其灵活的库,我想蓝图绝对应该算上一个,部署蓝图以后,你会发现整个程序结构非常清晰,模块之间相互不影响.蓝图对restfu ...

  9. 使用Jax-rs 开发RESTfull API 入门

    使用Jax-rs 开发RESTfull API 入门 本文使用 Jersey 2开发RESTfull API.Jersey 2 是 JAX-RS 接口的参考实现 使用到的工具 Eclipse Neon ...

随机推荐

  1. 服务器负载、CPU性能判断

    说在前面: 在linux操作系统中,我们一般查看系统的cpu负载情况常用的命令可以是uptime,top,还有vmstat等这些个都是可以有的.每个工具所提供的信息各不相同, 我这里要讨论的仅说cpu ...

  2. Python面试题之Python反射详解

    0x00 前言 反射,可以理解为利用字符串的形式去对象中操作成员属性和方法 反射的这点特性让我联想到了exec函数,也是把利用字符串的形式去让Python解释器去执行命令 Python Version ...

  3. MySQL "java.lang.IllegalArgumentException: HOUR_OF_DAY: 2 -> 3" 问题解析

    抛出异常截图: 异常原因 系统时区原因. 解决办法 在数据库连接串加上 &serverTimezone=Asia/Shanghai 即可~ conn_str="jdbc:mysql: ...

  4. (Matlab)GPU计算简介,及其与CPU计算性能的比较

    1.GPU与CPU结构上的对比 2.GPU能加速我的应用程序吗? 3.GPU与CPU在计算效率上的对比 4.利用Matlab进行GPU计算的一般流程 5.GPU计算的硬件.软件配置 5.1 硬件及驱动 ...

  5. 【联网】虚拟机下Linux(终端)配置网络的方法

    这几天在虚拟机vmware上部署centos系统,想通过内部联网用yum命令安装必需的软件,但是一直不能静态地址联网,今天终于找到一个方法centos内部设置IP,对外联网.设置过程如下: 1.首先是 ...

  6. Python学习札记(二十九) 模块2

    参考:使用模块 NOTE 1.内建sys模块: #!/usr/bin/env python3 import sys 'a test module' __author__ = 'wasdns' def ...

  7. python yaml文件读写

    import yaml yaml_dict={"} with open("a.yaml", "w") as f: yaml.safe_dump(yam ...

  8. egg.js npm start 启动报错

    开发环境运行项目即npm run dev的时候是正常的,但是npm start会启动失败,最可能的原因是因为npm start启动使用egg-scripts机制启动,对于运行中遇到error日志就会中 ...

  9. 10个有趣的Javascript和CSS库

    Tailwind CSS Tailwind是用于构建自定义用户界面的实用CSS框架. 每个Tailwind小应用都有多种尺寸,这使得创建响应式界面变得非常简单. 您可以自定义颜色,边框尺寸,字体,阴影 ...

  10. System.ComponentModel.DataAnnotations 命名空间和RequiredAttribute 类

    System.ComponentModel.DataAnnotations 命名空间提供定义 ASP.NET MVC 和 ASP.NET 数据控件的类的特性. RequiredAttribute 指定 ...