Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GraphQL

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

 GraphQL

Alexander Saenko

Avatar for Alexander Saenko

Alexander Saenko

January 26, 2019
Tweet

More Decks by Alexander Saenko

Other Decks in Programming

Transcript

  1. GRAPHQL ▸ Data query and manipulation language ▸ Open Source

    ▸ Created by Facebook ▸ 10k stars on GitHub ▸ Always* backward-compatible
  2. { "id": 118, "status": 0, "name": "The text you need",

    "due_date": 1498861069, "created_date": 1498256269, "updated_date": 1498741329, "description": "Something you definitely don't need", "is_modified": 1, "modified_by": "Alexander Saenko", "tasks": [ { "id": 38, "name": "The first task", "description": "Something about the task"}, { "id": 41, "name": "The second task", "description": "Something about the second task" } ] }
  3. { "id": 118, "status": 0, "name": "The text you need",

    "due_date": 1498861069, "created_date": 1498256269, "updated_date": 1498741329, "description": "Something you definitely don't need", "is_modified": 1, "modified_by": "Alexander Saenko", "tasks": [ { "id": 38, "name": "The first task", "description": "Something about the task"}, { "id": 41, "name": "The second task", "description": "Something about the second task" } ] }
  4. { "id": 118, "status": 0, "name": "The text you need",

    "due_date": 1498861069, "created_date": 1498256269, "updated_date": 1498741329, "description": "Something you definitely don't need", "is_modified": 1, "modified_by": "Alexander Saenko", "tasks_count": 2 [ { "id": 38, "name": "The first task", "description": "Something about the task"}, { "id": 41, "name": "The second task", "description": "Something about the second task" } ] }
  5. { "id": 118, "status": 0, "name": "The text you need",

    "updated_date": 1498741329, "tasks_count": 2 }
  6. struct TableModel: Codable { let id: Int let status: Bool

    let name: String let updatedDate: Date let tasksCount: Int enum CodingKeys:String, CodingKey { case id case status case name case updatedDate = "updated_date" case tasksCount = "tasks_count" } }
  7. struct TableModel: Codable { let id: Int let status: Bool

    let name: String let updatedDate: Date let tasksCount: Int enum CodingKeys:String, CodingKey { case id case status case name case updatedDate = "updated_date" case tasksCount = "tasks_count" } }
  8. export function TableModel(data) { return { id () { return

    data.id; }, status() { return data.status; }, name() { return data.name; }, updatedDate() { return new Date(data.updated_date * 1000); }, tasksCount() { return data.tasks.length; } } }
  9. { "id": 118, "status": 0, "name": "The text you need",

    "updatedDate": 1498741329, "tasksCount": 2 } struct TableModel: Codable { let id: Int let status: Bool let name: String let updatedDate: Date let tasksCount:Int }
  10. { "id": 118, "status": 0, "is_completed": false, "name": "The text

    you need", "updated_date": 1498741329, "tasks_count": 2 }
  11. type TableModel { id: Int! status: Boolean! @deprecated isCompleted: Boolean!

    name: String! updatedDate: Date! tasksCount: Int! }
  12. export function TableModel(data) { return { id () { return

    data.id; }, status() { return data.is_completed; }, isCompleted() { return data.is_completed; }, name() { return data.name; }, updatedDate() { return new Date(data.updated_date * 1000); }, tasksCount() { return data.tasks_count; } } }
  13. WHEN TO USE ▸ No breaking changes in API ▸

    Client-driven API ▸ Minimum network pressure