GraphQL
GraphQL
GraphQL is Facebook’s new query language for fetching application data in a uniform way.

但是就像所有强大的抽象一样,它提供的是一种折衷方案,团队要认真考虑,以避免长线上的负面影响。比如,我们已经看到有团队通过聚合工具暴露了过多的底层实现细节,导致架构出现了不必要的脆弱性。当团队试图借助聚合工具来创建规范化的、通用的、中心化的数据模型时,就会把短线上的便利变成长线上的麻烦。我们鼓励团队使用
GraphQL 与REST
经典的
不过
还是需要强调一点,引入
{
latestPost {
_id
title
content
author {
name
}
comments {
content
author {
name
}
}
}
}
这是一个很典型的
{
"data": {
"latestPost": {
"_id": "03390abb5570ce03ae524397d215713b",
"title": "New Feature: Tracking Error Status with Kadira",
"content": "Here is a common feedback we received from our users ...",
"author": {
"name": "Pahan Sarathchandra"
},
"comments": [
{
"content": "This is a very good blog post",
"author": {
"name": "Arunoda Susiripala"
}
},
{
"content": "Keep up the good work",
"author": {
"name": "Kasun Indi"
}
}
]
}
}
}
而如果采用
{
user(id:1) {
name
title
avatarUrl
timezone
locale
lastSeenOnline
email
phone
location
accountOwner {
name
avatarUrl
}
tags {
edges {
node {
label
color
}
}
}
accountUsers(first:10) {
edges {
node {
id
avatarUrl
}
}
pageInfo {
totalAccountUsers
}
}
recentConversations(first:10) {
edges {
node {
lastMessage
updatedAt
status
}
pageInfo {
totalConversationCount
}
}
}
}
}