Giter Site home page Giter Site logo

graphql.js-and-mock.js's Introduction

GraphQL本地查询mock数据demo

目录安装

  • git colne

  • npm install

说明

利用graphql单次查询mock.js模拟的静态数据

本地通过mock.js 生成前端数据

通过js动态渲染查询结果
生成一系列数据
分享者和被分享者数据的内容分开

目录结构

├─css

├─dist

└─js

GraphQL和其他API查询设计的优劣

  • GraphQL 定义了一套严谨的查询语言。REST API 在此毫无建树,基本上 API 的 querystring / body 没有太多章法可循,大家随遇而安。由此,GraphQL 可以很容易地通过类型系统和用户定义的 schema 生成强大的验证工具,保证 query 是正确的,且满足服务器的能力。
  • 使用 GraphQL 并不意味着能提高 API 效率。 GraphQL 只定义了 API 的 UI 部分,是否比 REST API 高效取决于实现的方式。事实上,不经优化 的 GraphQL API 的性能一般会比 REST API 低。因为 GraphQL 每个 field 单独 resolve,很容易出现 N+1 query。nodejs 的 GraphQL 实现考虑了这个问题,提供了 loader 允许更高效的查询方式。所以,在 resolve 的时候,一定要合理地使用 loader。
  • GraphQL 的强大灵活的查询能力虽然让人大流口水,但隐含着很多安全上和性能上的问题。
  • 旧有的缓存机制可能会失效
  • 用 GraphQL 可能会增加实现的复杂度

graphql.js-and-mock.js's People

Contributors

ohiamfine avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

faye993110

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.