Giter Site home page Giter Site logo

graphql-mock-server's Introduction

简介

适合: 作为中小型graphql应用的 mock server
不适合正式项目(因为目录结构基本是按 mock 数据要求而规划的)

为什么不直接使用 apollo server 的 mock ?

生成的数据是随机数, 太过简单
数据之间缺乏关联, 不仅难以验证逻辑, 而且关联数据的缺失, 还会导致前端报错
最好的 mock 数据, 是与后台真实数据结构相同, 并且相互关联的真实数据

其它选择: 如果你不使用 subscription, 并且没有复杂的关联数据, 推荐: https://github.com/marmelab/json-graphql-server

包含哪些内容

  1. graphql server, 未整合 express
  2. token认证(使用 uuid 作为 token, 可以很容易地抽换为 jwt )
  3. 合理的目录规划(注意这个目录规划仅适合用于 mock-server, 如果是正式项目, 需要大幅改动)
  4. 演示grapqhql的用法, 包含 subscription

快速上手(作为 mock server)

假设你的前端项目名为: front_project, 那么: 第一步: 启动 mock

cd front_project
git clone https://github.com/g770728y/graphql-mock-server $your-mock-server-name

cd $your-mock-server-name
yarn
yarn dev

第二步: 连接到 client

cd front_project
将 `uri` 改成 http://localhost:3999/graphql

第三步: 参照 src/desk 等目录, 编写自己的 mock 数据

graphql-mock-server's People

Contributors

g770728y avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.