Publish / Subscribe
感動と驚きを与えてくれる、が、"マジック"
Subscribe, then query
Server decide what to send
Reactivity from live database query
Schema in user code
Require websocket DDP client
Database query language
Subscribe, then query
Client decide what to request
Reactivity on top of request/response
Schema built into GraphQL
Can be queried with basic HTTP
Application-level query language
Web Application
Android
iOS
Desk top Application
Application Layer
SQL
NoSQL
REST
Data Layer
GraphQL
意訳:開発者(バックエンド・フロントエンドともに)がお互いにハッピーになれるように
エンドポイントを1つにすることで、
バックエンドは、
{
geek {
name
age
}
}
{
"geek": [{
"name" : "teymmt",
"age" : "unknown"
}]
}
Query
Result
(from a app)
(from graphql sever)
Shemaを定義したり、Data sourceとの紐付けを定義したりする必要がある
Apollo Client now provides simple tools to work with mutations while keeping store updates and rerenders efficient.
Whenever we create a new task in a todo list, or remove an image from a grid — we can simulate the result by guessing what will happen, and then validate the behavior with the server.
The trick is to update the UI state with a fake response first, and then re-validate it once the server responses. This is what we call Optimistic UI.
const client = new ApolloClient({
// ... other options ...
shouldBatch: true,
});
// these queries may be loaded from two different places within your
// code.
// the two queries above will be sent in one request.
client.query({ query: query1 })
client.query({ query: query2 })
The query batcher operates on “ticks” — it checks a queue every 10 milliseconds to see if there are any pending queries.