Coder Social home page Coder Social logo

zbj_homework's Introduction

GraphQL vs REST

REST

REST 指的是一组架构约束条件和原则,满足这些约束条件和原则的应用程序或设计就是 RESTFul

REST 适合于简单逻辑的查询请求,不适合复杂的资源请求,对于具有复杂资源间关联的请求,可能需要进行多次查询请求

RESTful 查询方式:

GET /tracks/ID

GET /playlists/ID

GET /playlists/ID/tracks

GraphQL

GraphQL 可以看做一个业务逻辑层灵活有效的辅助工具,处在前端和后台之间的中间层

GraphQL 是一个数据抽象层,包括数据格式、数据关联、查询方式定义与实现等等。

GraphQL 通过对于多个 REST 风格的简单的借口的排列组合提供更多复杂多变的查询方式

GraphQL 有一个 schema 和静态 types ,并且限制了数据的类型

GraphQL 查询方式:

graphql.query(`
{
    latestPost {
    	_id,
        title,
        content,
        author {
            name
        },
        comments {
            content,
            author {
            	name
            }
        }
    }
}
`);

zbj_homework's People

Contributors

6ml 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.