作用

  • 代码生成

  • 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. 2016-2017 CT S03E07: Codeforces Trainings Season 3 Episode 7

    B. Pen Pineapple Apple Pen Solved. 题意:将一个序列合并成一个数. 思路:分类讨论一下, 水. #include<bits/stdc++.h> using ...

  2. python 字节字符串上的字符串操作

    问题:想在字节字符串上执行普通的文本操作(比如移除,搜索和替换). 解决方案 1)字节字符串同样也支持大部分和文本字符串一样的内置操作.比如: >>> data = b'Hello ...

  3. laravel 中间件排除

    public function __construct(){ //除了主页之外 $this->middleware('auth', ['except' => ['index','show' ...

  4. # 20145106 《Java程序设计》第4周学习总结

    教材学习内容总结 翻开第六章的书,发现书中的例子居然是"假设我正在开发一款rpg游戏" public class Magician extends Role { public vo ...

  5. HBase参数优化

    zookeeper.session.timeout默认值:3分钟(180000ms)说明:RegionServer与Zookeeper间的连接超时时间.当超时时间到后,ReigonServer会被Zo ...

  6. Redis之hash数据结构实现

    参考 https://www.cnblogs.com/ourroad/p/4891648.html https://blog.csdn.net/hjkl950217/article/details/7 ...

  7. Codeforces Round #278 (Div. 2) D. Strip 线段树优化dp

    D. Strip time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...

  8. 读underscore

    最近在拜读只有1700行(含注释)代码的Underscore.js 1.9.1,记录一些东西 (参考https://underscorejs.org/underscore.js,https://git ...

  9. UVALive-3268 Jamie's Contact Groups (最大流,网络流建模)

    题目大意:你的手机通讯录里有n个联系人,m个分组,其中,有的联系人在多个分组里.你的任务是在一些分组里删除一些联系人,使得每个联系人只在一个分组里并且使人数最多的那个分组人数最少.找出人数最多的那个分 ...

  10. 从排序后的结果集中删除 前n条记录

    端午有人休息,有人忙 操作前数据: --从排序后的结果集中删除 前n条记录delete from emp where empno in (select empno                   ...