SlideShare une entreprise Scribd logo
1  sur  49
Télécharger pour lire hors ligne
Interfacing with GraphQL in Swift
Sommer Panage • @sommer
1 — Sommer Panage • @sommer • Swift Summit 2016
Hello!
2 — Sommer Panage • @sommer • Swift Summit 2016
What is GraphQL?
3 — Sommer Panage • @sommer • Swift Summit 2016
The GraphQL Schema
type User {
name: String!
id: Int!
email: String
twitter: String
}
4 — Sommer Panage • @sommer • Swift Summit 2016
Instead of hitting a REST endpoint like...
https://mybackend.com/api/user?id=1
5 — Sommer Panage • @sommer • Swift Summit 2016
I write a query like...
{
user(id: 1) {
name
email
twitter
}
}
And send it to my GraphQL endpoint
https://mybackend.com/graphql
6 — Sommer Panage • @sommer • Swift Summit 2016
And I get back a JSON response like...
{
"data": {
"name": "Sommer Panage",
"email": "sommer@panage.org",
"twitter": "@sommer"
}
}
7 — Sommer Panage • @sommer • Swift Summit 2016
Why is GraphQL such a
big deal for mobile?
8 — Sommer Panage • @sommer • Swift Summit 2016
Let's write an app
9 — Sommer Panage • @sommer • Swift Summit 2016
In a REST world, we'd hit this endpoint:
http://swapi.co/api/people/1/
And we'd get back...
10 — Sommer Panage • @sommer • Swift Summit 2016
{
"name": "Luke Skywalker",
"height": "1.72 m",
"mass": "77 Kg",
"hair_color": "Blond",
"skin_color": "Caucasian",
"eye_color": "Blue",
"birth_year": "19 BBY",
"gender": "Male",
"homeworld": "http://swapi.co/api/planets/1/",
"films": [
"http://swapi.co/api/films/1/",
"http://swapi.co/api/films/2/",
"http://swapi.co/api/films/3/"
],
"species": [
"http://swapi.co/api/species/1/"
],
"vehicles": [
"http://swapi.co/api/vehicles/14/",
"http://swapi.co/api/vehicles/30/"
],
"starships": [
"http://swapi.co/api/starships/12/",
"http://swapi.co/api/starships/22/"
],
"created": "2014-12-09T13:50:51.644000Z",
"edited": "2014-12-10T13:52:43.172000Z",
"url": "http://swapi.co/api/people/1/",
"image_url": "http://static.srcdn.com/wp-content/uploads/luke-skywalker-star-wars-a-new-hope.jpg"
}
11 — Sommer Panage • @sommer • Swift Summit 2016
And then...we'd make two more calls to...
http://swapi.co/api/starships/12/
and
http://swapi.co/api/starships/22/
12 — Sommer Panage • @sommer • Swift Summit 2016
{
"name": "X-wing",
"model": "T-65 X-wing",
"manufacturer": "Incom Corporation",
"cost_in_credits": "149999",
"length": "12.5",
"max_atmosphering_speed": "1050",
"crew": "1",
"passengers": "0",
"cargo_capacity": "110",
"consumables": "1 week",
"hyperdrive_rating": "1.0",
"MGLT": "100",
"starship_class": "Starfighter",
"pilots": [
"http://swapi.co/api/people/1/",
"http://swapi.co/api/people/9/",
"http://swapi.co/api/people/18/",
"http://swapi.co/api/people/19/"
],
"films": [
"http://swapi.co/api/films/3/",
"http://swapi.co/api/films/2/",
"http://swapi.co/api/films/1/"
],
"created": "2014-12-12T11:19:05.340000Z",
"edited": "2014-12-22T17:35:44.491233Z",
"url": "http://swapi.co/api/starships/12/"
}
13 — Sommer Panage • @sommer • Swift Summit 2016
{
"name": "Imperial shuttle",
"model": "Lambda-class T-4a shuttle",
"manufacturer": "Sienar Fleet Systems",
"cost_in_credits": "240000",
"length": "20",
"max_atmosphering_speed": "850",
"crew": "6",
"passengers": "20",
"cargo_capacity": "80000",
"consumables": "2 months",
"hyperdrive_rating": "1.0",
"MGLT": "50",
"starship_class": "Armed government transport",
"pilots": [
"http://swapi.co/api/people/1/",
"http://swapi.co/api/people/13/",
"http://swapi.co/api/people/14/"
],
"films": [
"http://swapi.co/api/films/3/",
"http://swapi.co/api/films/2/"
],
"created": "2014-12-15T13:04:47.235000Z",
"edited": "2014-12-22T17:35:44.795405Z",
"url": "http://swapi.co/api/starships/22/"
}
14 — Sommer Panage • @sommer • Swift Summit 2016
That's 3 calls and a whole lot of data for 1 little VC
15 — Sommer Panage • @sommer • Swift Summit 2016
Now in GraphQL, instead we'd write the following query:
{
person(personID: 1) {
name,
height,
mass,
hairColor,
eyeColor,
imageURL,
starshipConnection {
edges {
node {
name
}
}
}
}
}
16 — Sommer Panage • @sommer • Swift Summit 2016
And, I'd get back exactly what I wanted!
{
"data": {
"person": {
"name": "Luke Skywalker",
"height": 172,
"mass": 77,
"hairColor": "blond",
"eyeColor": "blue",
"imageURL": "http://static.srcdn.com/wp-content/uploads/luke-skywalker-star-wars-a-new-hope.jpg",
"starshipConnection": {
"edges": [
{
"node": {
"name": "X-wing"
}
},
{
"node": {
"name": "Imperial shuttle"
}
}
]
}
}
}
}
17 — Sommer Panage • @sommer • Swift Summit 2016
So, why is GraphQL such a big deal for mobile?
1. Ask and ye shall receive!
2. Fewer round trips!
3. Less client logic around data!
18 — Sommer Panage • @sommer • Swift Summit 2016
Wait just a minute...
19 — Sommer Panage • @sommer • Swift Summit 2016
Our Star Wars Character model
struct SWCharacter {
let name: String
let heightInCm: Int
let massInKg: Int
let hairColorDescriptor: String
let skinColorDescriptor: String
let eyeColorDescriptor: String
let birthYear: StarWarsUniverse.Year
let gender: StarWarsUniverse.Gender
let homeworld: StarWarsUniverse.Planet
let films: [SWFilm]
let species: [StarWarsUniverse.Species]
let vehicles: [StarWarsUniverse.Vehicle]
let starships: [StarWarsUniverse.Starship]
let imageURL: URL?
}
20 — Sommer Panage • @sommer • Swift Summit 2016
Our Star Wars Character model
struct SWCharacter {
let name: String?
let heightInCm: Int?
let massInKg: Int?
let hairColorDescriptor: String?
let skinColorDescriptor: String?
let eyeColorDescriptor: String
let birthYear: StarWarsUniverse.Year?
let gender: StarWarsUniverse.Gender?
let homeworld: StarWarsUniverse.Planet?
let films: [SWFilm]?
let species: [StarWarsUniverse.Species]?
let vehicles: [StarWarsUniverse.Vehicle]?
let starships: [StarWarsUniverse.Starship]?
let imageURL: URL?
}
21 — Sommer Panage • @sommer • Swift Summit 2016
Swift, No!!!!
struct SWCharacter {
let name: String?
let heightInCm: Int?
let massInKg: Int?
let hairColorDescriptor: String?
let skinColorDescriptor: String?
let eyeColorDescriptor: String
let birthYear: StarWarsUniverse.Year?
let gender: StarWarsUniverse.Gender?
let homeworld: StarWarsUniverse.Planet?
let films: [SWFilm]?
let species: [StarWarsUniverse.Species]?
let vehicles: [StarWarsUniverse.Vehicle]?
let starships: [StarWarsUniverse.Starship]?
let imageURL: URL?
}
22 — Sommer Panage • @sommer • Swift Summit 2016
23 — Sommer Panage • @sommer • Swift Summit 2016
Let's model the data how we want it, not how it is
→ 1 View Controller
→ 1 Query
→ 1 Data Model
24 — Sommer Panage • @sommer • Swift Summit 2016
25 — Sommer Panage • @sommer • Swift Summit 2016
query AllCharacters {
allPeople {
edges {
node {
id
name
homeworld {
name
}
}
}
}
}
26 — Sommer Panage • @sommer • Swift Summit 2016
struct AllCharactersData {
let people: [Person]
struct Person {
let id: String
let name: String
let homeworld: Homeworld
struct Homeworld {
let name: String
}
}
}
27 — Sommer Panage • @sommer • Swift Summit 2016
query Character($id: ID) {
person (id: $id) {
id
height,
mass,
hairColor,
eyeColor,
imageURL,
starshipConnection {
edges {
node {
name
}
}
}
}
}
28 — Sommer Panage • @sommer • Swift Summit 2016
struct CharacterData {
struct Person {
let id: String
let height: Int
let mass: Int
let hairColor: String
let eyeColor: String
let imageURL: URL?
let starshipConnect: [Starship]
struct Starship {
let name: String
}
}
}
29 — Sommer Panage • @sommer • Swift Summit 2016
By having query / view-
data based models, we
no longer need optionals
everywhere!
30 — Sommer Panage • @sommer • Swift Summit 2016
But our parsing code still looks like...
let parsedData = try JSONSerialization.jsonObject(with: data, options: []) as! [String: Any]
self.id = parsedData["id"] as! String
self.name = parsedData["name"] as! String
self.homeworld = Homeworld(dict: parsedData["homeworld"] as! [String : Any])
Ugh!
31 — Sommer Panage • @sommer • Swift Summit 2016
Code Gen!
32 — Sommer Panage • @sommer • Swift Summit 2016
33 — Sommer Panage • @sommer • Swift Summit 2016
Apollo's iOS GraphQL Client for Swift
→ Compile-time safety
→ Inline validation errors for GraphQL
→ No wasted cycles on query-gen
34 — Sommer Panage • @sommer • Swift Summit 2016
What about...?
35 — Sommer Panage • @sommer • Swift Summit 2016
Versioning
→ "Version-Free"
→ Easy to test for backwards compatability
36 — Sommer Panage • @sommer • Swift Summit 2016
Caching
37 — Sommer Panage • @sommer • Swift Summit 2016
Simple Caching
Query-based, not object based
38 — Sommer Panage • @sommer • Swift Summit 2016
Advanced Caching
Flattened results, id-record mapped
39 — Sommer Panage • @sommer • Swift Summit 2016
Aren't you supposed to
use GraphQL with React
Native?
40 — Sommer Panage • @sommer • Swift Summit 2016
GraphQL + Swift
-> GraphQL shines on mobile
-> Swift gives us types and compile time safety
-> React Native is new and exciting, but that comes
with challenges too
41 — Sommer Panage • @sommer • Swift Summit 2016
In
Conclusion...
42 — Sommer Panage • @sommer • Swift Summit 2016
Pros to GraphQL + Swift
→ Fewer requests for data
→ Getting the exact data you need
→ Code gen -> no janky parsing code
→ Models that are reflective of your views
→ A strongly typed backend schema
43 — Sommer Panage • @sommer • Swift Summit 2016
Cons to GraphQL + Swift
→ Not a lot of tooling yet
→ Best practices still emerging
→ Poorly defined schema becomes a big client
problem
→ Not as good for endpoints requiring heavy logic
44 — Sommer Panage • @sommer • Swift Summit 2016
tldr: It's worth
it!
45 — Sommer Panage • @sommer • Swift Summit 2016
Check out
→ Apollo iOS Client: Documentation and info on
Apollo's awesome Swift iOS GraphQL client
→ 5 benefits of static GraphQL Queries: Blog post
from Apollo
→ Bringing GraphQL to iOS: Blog post from Apollo
→ GraphQL First: A better way to build modern apps:
Blog post from Apollo
46 — Sommer Panage • @sommer • Swift Summit 2016
Check out...con’t
→ GraphQL for mobile: Blog post from Artsy
→ Relay: Thinking in GraphQL: Post from FB on
Caching
47 — Sommer Panage • @sommer • Swift Summit 2016
Thank you!!
Come ask me questions about GraphQL + Swift
or about Accessibility!
48 — Sommer Panage • @sommer • Swift Summit 2016
Credits
Images
GediminasTurbo Baltaduonis, Danil Polshin, Apple,
Facebook, Apollo, Lucasfilm
General
Chorus Fitness, Apollo, Facebook
49 — Sommer Panage • @sommer • Swift Summit 2016

Contenu connexe

Tendances

How to build a social network on Serverless (AWS Community Summit)
How to build a social network on Serverless (AWS Community Summit)How to build a social network on Serverless (AWS Community Summit)
How to build a social network on Serverless (AWS Community Summit)Yan Cui
 
Infrastructure as code
Infrastructure as codeInfrastructure as code
Infrastructure as codedaisuke awaji
 
Agile Development with OSGi
Agile Development with OSGiAgile Development with OSGi
Agile Development with OSGiMatt Stine
 
How to build observability into a serverless application
How to build observability into a serverless applicationHow to build observability into a serverless application
How to build observability into a serverless applicationYan Cui
 
Manage any AWS resources with Terraform 0.12 - April 2020
Manage any AWS resources with Terraform 0.12 - April 2020Manage any AWS resources with Terraform 0.12 - April 2020
Manage any AWS resources with Terraform 0.12 - April 2020Anton Babenko
 
Integrating-Cloud-Development-Security-And-Operations.pdf
Integrating-Cloud-Development-Security-And-Operations.pdfIntegrating-Cloud-Development-Security-And-Operations.pdf
Integrating-Cloud-Development-Security-And-Operations.pdfAmazon Web Services
 
Concourse x Spinnaker #concourse_tokyo
Concourse x Spinnaker #concourse_tokyoConcourse x Spinnaker #concourse_tokyo
Concourse x Spinnaker #concourse_tokyoToshiaki Maki
 
Developer Experience at the Guardian, Equal Experts Sept 2021
Developer Experience at the Guardian, Equal Experts Sept 2021Developer Experience at the Guardian, Equal Experts Sept 2021
Developer Experience at the Guardian, Equal Experts Sept 2021Akash Askoolum
 
Spring ❤️ Kotlin #jjug
Spring ❤️ Kotlin #jjugSpring ❤️ Kotlin #jjug
Spring ❤️ Kotlin #jjugToshiaki Maki
 
Secure Architecture and Programming 101
Secure Architecture and Programming 101Secure Architecture and Programming 101
Secure Architecture and Programming 101Mario-Leander Reimer
 
Istio By Example (extended version)
Istio By Example (extended version)Istio By Example (extended version)
Istio By Example (extended version)Josef Adersberger
 
Serverless Media Workflow
Serverless Media WorkflowServerless Media Workflow
Serverless Media WorkflowMooYeol Lee
 
Integrating_Cloud_Development_Security_And_Operations.pdf
Integrating_Cloud_Development_Security_And_Operations.pdfIntegrating_Cloud_Development_Security_And_Operations.pdf
Integrating_Cloud_Development_Security_And_Operations.pdfAmazon Web Services
 
Secured API Acceleration with Engineers from Amazon CloudFront and Slack
Secured API Acceleration with Engineers from Amazon CloudFront and SlackSecured API Acceleration with Engineers from Amazon CloudFront and Slack
Secured API Acceleration with Engineers from Amazon CloudFront and SlackAmazon Web Services
 
Fluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting realFluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting realAkamai Developers & Admins
 
Where Node.JS Meets iOS
Where Node.JS Meets iOSWhere Node.JS Meets iOS
Where Node.JS Meets iOSSam Rijs
 
Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Yan Cui
 
Patterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservicesPatterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservicesRachel Reese
 
Managing your Docker image continuously with Concourse CI
Managing your Docker image continuously with Concourse CIManaging your Docker image continuously with Concourse CI
Managing your Docker image continuously with Concourse CIToshiaki Maki
 
Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...
Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...
Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...Amazon Web Services
 

Tendances (20)

How to build a social network on Serverless (AWS Community Summit)
How to build a social network on Serverless (AWS Community Summit)How to build a social network on Serverless (AWS Community Summit)
How to build a social network on Serverless (AWS Community Summit)
 
Infrastructure as code
Infrastructure as codeInfrastructure as code
Infrastructure as code
 
Agile Development with OSGi
Agile Development with OSGiAgile Development with OSGi
Agile Development with OSGi
 
How to build observability into a serverless application
How to build observability into a serverless applicationHow to build observability into a serverless application
How to build observability into a serverless application
 
Manage any AWS resources with Terraform 0.12 - April 2020
Manage any AWS resources with Terraform 0.12 - April 2020Manage any AWS resources with Terraform 0.12 - April 2020
Manage any AWS resources with Terraform 0.12 - April 2020
 
Integrating-Cloud-Development-Security-And-Operations.pdf
Integrating-Cloud-Development-Security-And-Operations.pdfIntegrating-Cloud-Development-Security-And-Operations.pdf
Integrating-Cloud-Development-Security-And-Operations.pdf
 
Concourse x Spinnaker #concourse_tokyo
Concourse x Spinnaker #concourse_tokyoConcourse x Spinnaker #concourse_tokyo
Concourse x Spinnaker #concourse_tokyo
 
Developer Experience at the Guardian, Equal Experts Sept 2021
Developer Experience at the Guardian, Equal Experts Sept 2021Developer Experience at the Guardian, Equal Experts Sept 2021
Developer Experience at the Guardian, Equal Experts Sept 2021
 
Spring ❤️ Kotlin #jjug
Spring ❤️ Kotlin #jjugSpring ❤️ Kotlin #jjug
Spring ❤️ Kotlin #jjug
 
Secure Architecture and Programming 101
Secure Architecture and Programming 101Secure Architecture and Programming 101
Secure Architecture and Programming 101
 
Istio By Example (extended version)
Istio By Example (extended version)Istio By Example (extended version)
Istio By Example (extended version)
 
Serverless Media Workflow
Serverless Media WorkflowServerless Media Workflow
Serverless Media Workflow
 
Integrating_Cloud_Development_Security_And_Operations.pdf
Integrating_Cloud_Development_Security_And_Operations.pdfIntegrating_Cloud_Development_Security_And_Operations.pdf
Integrating_Cloud_Development_Security_And_Operations.pdf
 
Secured API Acceleration with Engineers from Amazon CloudFront and Slack
Secured API Acceleration with Engineers from Amazon CloudFront and SlackSecured API Acceleration with Engineers from Amazon CloudFront and Slack
Secured API Acceleration with Engineers from Amazon CloudFront and Slack
 
Fluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting realFluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting real
 
Where Node.JS Meets iOS
Where Node.JS Meets iOSWhere Node.JS Meets iOS
Where Node.JS Meets iOS
 
Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)
 
Patterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservicesPatterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservices
 
Managing your Docker image continuously with Concourse CI
Managing your Docker image continuously with Concourse CIManaging your Docker image continuously with Concourse CI
Managing your Docker image continuously with Concourse CI
 
Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...
Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...
Remove Undifferentiated Heavy Lifting from Jenkins (DEV201-R1) - AWS re:Inven...
 

En vedette

Writing Your App Swiftly
Writing Your App SwiftlyWriting Your App Swiftly
Writing Your App SwiftlySommer Panage
 
GraphQL IndyJS April 2016
GraphQL IndyJS April 2016GraphQL IndyJS April 2016
GraphQL IndyJS April 2016Brad Pillow
 
Zensations Drupal 8 GraphQL Presentation 2015
Zensations Drupal 8 GraphQL Presentation 2015Zensations Drupal 8 GraphQL Presentation 2015
Zensations Drupal 8 GraphQL Presentation 2015Zensations GmbH
 
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...将之 小野
 
GraphQL Relay Introduction
GraphQL Relay IntroductionGraphQL Relay Introduction
GraphQL Relay IntroductionChen-Tsu Lin
 
Relay: Seamless Syncing for React (VanJS)
Relay: Seamless Syncing for React (VanJS)Relay: Seamless Syncing for React (VanJS)
Relay: Seamless Syncing for React (VanJS)Brooklyn Zelenka
 
Work with V8 memory leaks
Work with V8 memory leaksWork with V8 memory leaks
Work with V8 memory leaksRoman Krivtsov
 
はじめて Phantom と遭遇して、闇雲に闘いを挑んでみた話 #kbkz_tech
はじめて Phantom と遭遇して、闇雲に闘いを挑んでみた話 #kbkz_techはじめて Phantom と遭遇して、闇雲に闘いを挑んでみた話 #kbkz_tech
はじめて Phantom と遭遇して、闇雲に闘いを挑んでみた話 #kbkz_techTomohiro Kumagai
 
あなたのオブジェクト指向はオブジェクト指向ではないかもしれない
あなたのオブジェクト指向はオブジェクト指向ではないかもしれないあなたのオブジェクト指向はオブジェクト指向ではないかもしれない
あなたのオブジェクト指向はオブジェクト指向ではないかもしれない康廣 木目沢
 
#yidev 第25回勉強会 オープニング
#yidev 第25回勉強会 オープニング#yidev 第25回勉強会 オープニング
#yidev 第25回勉強会 オープニングTomohiro Kumagai
 
みんなで Swift 復習会での談笑用スライド – 3rd #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 3rd #minna_de_swiftみんなで Swift 復習会での談笑用スライド – 3rd #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 3rd #minna_de_swiftTomohiro Kumagai
 
勉強会のこちら側とあちら側
勉強会のこちら側とあちら側勉強会のこちら側とあちら側
勉強会のこちら側とあちら側Tomoki Hasegawa
 
Introduction to GraphQL at API days
Introduction to GraphQL at API daysIntroduction to GraphQL at API days
Introduction to GraphQL at API daysyann_s
 
JVM言語を使ってみようの歌
JVM言語を使ってみようの歌JVM言語を使ってみようの歌
JVM言語を使ってみようの歌YujiSoftware
 
Migration microservices to GraphQL
Migration microservices to GraphQLMigration microservices to GraphQL
Migration microservices to GraphQLRoman Krivtsov
 
Java in the Past, Java in the Future
Java in the Past, Java in the FutureJava in the Past, Java in the Future
Java in the Past, Java in the FutureYuichi Sakuraba
 
みんなで Swift 復習会での談笑用スライド – 5th #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 5th #minna_de_swiftみんなで Swift 復習会での談笑用スライド – 5th #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 5th #minna_de_swiftTomohiro Kumagai
 
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swift
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swiftみんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swift
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swiftTomohiro Kumagai
 
GraphQL vs REST
GraphQL vs RESTGraphQL vs REST
GraphQL vs RESTGreeceJS
 

En vedette (20)

Writing Your App Swiftly
Writing Your App SwiftlyWriting Your App Swiftly
Writing Your App Swiftly
 
GraphQL IndyJS April 2016
GraphQL IndyJS April 2016GraphQL IndyJS April 2016
GraphQL IndyJS April 2016
 
Graphql
GraphqlGraphql
Graphql
 
Zensations Drupal 8 GraphQL Presentation 2015
Zensations Drupal 8 GraphQL Presentation 2015Zensations Drupal 8 GraphQL Presentation 2015
Zensations Drupal 8 GraphQL Presentation 2015
 
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
 
GraphQL Relay Introduction
GraphQL Relay IntroductionGraphQL Relay Introduction
GraphQL Relay Introduction
 
Relay: Seamless Syncing for React (VanJS)
Relay: Seamless Syncing for React (VanJS)Relay: Seamless Syncing for React (VanJS)
Relay: Seamless Syncing for React (VanJS)
 
Work with V8 memory leaks
Work with V8 memory leaksWork with V8 memory leaks
Work with V8 memory leaks
 
はじめて Phantom と遭遇して、闇雲に闘いを挑んでみた話 #kbkz_tech
はじめて Phantom と遭遇して、闇雲に闘いを挑んでみた話 #kbkz_techはじめて Phantom と遭遇して、闇雲に闘いを挑んでみた話 #kbkz_tech
はじめて Phantom と遭遇して、闇雲に闘いを挑んでみた話 #kbkz_tech
 
あなたのオブジェクト指向はオブジェクト指向ではないかもしれない
あなたのオブジェクト指向はオブジェクト指向ではないかもしれないあなたのオブジェクト指向はオブジェクト指向ではないかもしれない
あなたのオブジェクト指向はオブジェクト指向ではないかもしれない
 
#yidev 第25回勉強会 オープニング
#yidev 第25回勉強会 オープニング#yidev 第25回勉強会 オープニング
#yidev 第25回勉強会 オープニング
 
みんなで Swift 復習会での談笑用スライド – 3rd #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 3rd #minna_de_swiftみんなで Swift 復習会での談笑用スライド – 3rd #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 3rd #minna_de_swift
 
勉強会のこちら側とあちら側
勉強会のこちら側とあちら側勉強会のこちら側とあちら側
勉強会のこちら側とあちら側
 
Introduction to GraphQL at API days
Introduction to GraphQL at API daysIntroduction to GraphQL at API days
Introduction to GraphQL at API days
 
JVM言語を使ってみようの歌
JVM言語を使ってみようの歌JVM言語を使ってみようの歌
JVM言語を使ってみようの歌
 
Migration microservices to GraphQL
Migration microservices to GraphQLMigration microservices to GraphQL
Migration microservices to GraphQL
 
Java in the Past, Java in the Future
Java in the Past, Java in the FutureJava in the Past, Java in the Future
Java in the Past, Java in the Future
 
みんなで Swift 復習会での談笑用スライド – 5th #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 5th #minna_de_swiftみんなで Swift 復習会での談笑用スライド – 5th #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 5th #minna_de_swift
 
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swift
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swiftみんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swift
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swift
 
GraphQL vs REST
GraphQL vs RESTGraphQL vs REST
GraphQL vs REST
 

Similaire à Interfacing with GraphQL in Swift: A Mobile-First Approach

SETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventuresSETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventuresNadzeya Pus
 
Graphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiDGraphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiDCODEiD PHP Community
 
Web development with Lua @ Bulgaria Web Summit 2016
Web development with Lua @ Bulgaria Web Summit 2016Web development with Lua @ Bulgaria Web Summit 2016
Web development with Lua @ Bulgaria Web Summit 2016Etiene Dalcol
 
Everything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLMario-Leander Reimer
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureQAware GmbH
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Robert Schadek
 
Into to GraphQL
Into to GraphQLInto to GraphQL
Into to GraphQLshobot
 
Document Model for High Speed Spark Processing
Document Model for High Speed Spark ProcessingDocument Model for High Speed Spark Processing
Document Model for High Speed Spark ProcessingMongoDB
 
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...GreeceJS
 
Sparkling Water 5 28-14
Sparkling Water 5 28-14Sparkling Water 5 28-14
Sparkling Water 5 28-14Sri Ambati
 
Modernizes your objective C - Oliviero
Modernizes your objective C - OlivieroModernizes your objective C - Oliviero
Modernizes your objective C - OlivieroCodemotion
 
Sparkling Water Webinar October 29th, 2014
Sparkling Water Webinar October 29th, 2014Sparkling Water Webinar October 29th, 2014
Sparkling Water Webinar October 29th, 2014Sri Ambati
 
OpenAPI development with Python
OpenAPI development with PythonOpenAPI development with Python
OpenAPI development with PythonTakuro Wada
 
DevSecCon Singapore 2018 - in graph we trust By Imran Mohammed
DevSecCon Singapore 2018 - in graph we trust By Imran MohammedDevSecCon Singapore 2018 - in graph we trust By Imran Mohammed
DevSecCon Singapore 2018 - in graph we trust By Imran MohammedDevSecCon
 
In graph we trust: Microservices, GraphQL and security challenges
In graph we trust: Microservices, GraphQL and security challengesIn graph we trust: Microservices, GraphQL and security challenges
In graph we trust: Microservices, GraphQL and security challengesMohammed A. Imran
 
Testing API platform with Behat BDD tests
Testing API platform with Behat BDD testsTesting API platform with Behat BDD tests
Testing API platform with Behat BDD testsStefan Adolf
 
Big Data Processing with .NET and Spark (SQLBits 2020)
Big Data Processing with .NET and Spark (SQLBits 2020)Big Data Processing with .NET and Spark (SQLBits 2020)
Big Data Processing with .NET and Spark (SQLBits 2020)Michael Rys
 

Similaire à Interfacing with GraphQL in Swift: A Mobile-First Approach (20)

SETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventuresSETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventures
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
 
Symfony + GraphQL
Symfony + GraphQLSymfony + GraphQL
Symfony + GraphQL
 
Graphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiDGraphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiD
 
Web development with Lua @ Bulgaria Web Summit 2016
Web development with Lua @ Bulgaria Web Summit 2016Web development with Lua @ Bulgaria Web Summit 2016
Web development with Lua @ Bulgaria Web Summit 2016
 
Everything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPL
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventure
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...
 
Into to GraphQL
Into to GraphQLInto to GraphQL
Into to GraphQL
 
Document Model for High Speed Spark Processing
Document Model for High Speed Spark ProcessingDocument Model for High Speed Spark Processing
Document Model for High Speed Spark Processing
 
Spark and MongoDB
Spark and MongoDBSpark and MongoDB
Spark and MongoDB
 
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
 
Sparkling Water 5 28-14
Sparkling Water 5 28-14Sparkling Water 5 28-14
Sparkling Water 5 28-14
 
Modernizes your objective C - Oliviero
Modernizes your objective C - OlivieroModernizes your objective C - Oliviero
Modernizes your objective C - Oliviero
 
Sparkling Water Webinar October 29th, 2014
Sparkling Water Webinar October 29th, 2014Sparkling Water Webinar October 29th, 2014
Sparkling Water Webinar October 29th, 2014
 
OpenAPI development with Python
OpenAPI development with PythonOpenAPI development with Python
OpenAPI development with Python
 
DevSecCon Singapore 2018 - in graph we trust By Imran Mohammed
DevSecCon Singapore 2018 - in graph we trust By Imran MohammedDevSecCon Singapore 2018 - in graph we trust By Imran Mohammed
DevSecCon Singapore 2018 - in graph we trust By Imran Mohammed
 
In graph we trust: Microservices, GraphQL and security challenges
In graph we trust: Microservices, GraphQL and security challengesIn graph we trust: Microservices, GraphQL and security challenges
In graph we trust: Microservices, GraphQL and security challenges
 
Testing API platform with Behat BDD tests
Testing API platform with Behat BDD testsTesting API platform with Behat BDD tests
Testing API platform with Behat BDD tests
 
Big Data Processing with .NET and Spark (SQLBits 2020)
Big Data Processing with .NET and Spark (SQLBits 2020)Big Data Processing with .NET and Spark (SQLBits 2020)
Big Data Processing with .NET and Spark (SQLBits 2020)
 

Dernier

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 

Dernier (20)

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 

Interfacing with GraphQL in Swift: A Mobile-First Approach

  • 1. Interfacing with GraphQL in Swift Sommer Panage • @sommer 1 — Sommer Panage • @sommer • Swift Summit 2016
  • 2. Hello! 2 — Sommer Panage • @sommer • Swift Summit 2016
  • 3. What is GraphQL? 3 — Sommer Panage • @sommer • Swift Summit 2016
  • 4. The GraphQL Schema type User { name: String! id: Int! email: String twitter: String } 4 — Sommer Panage • @sommer • Swift Summit 2016
  • 5. Instead of hitting a REST endpoint like... https://mybackend.com/api/user?id=1 5 — Sommer Panage • @sommer • Swift Summit 2016
  • 6. I write a query like... { user(id: 1) { name email twitter } } And send it to my GraphQL endpoint https://mybackend.com/graphql 6 — Sommer Panage • @sommer • Swift Summit 2016
  • 7. And I get back a JSON response like... { "data": { "name": "Sommer Panage", "email": "sommer@panage.org", "twitter": "@sommer" } } 7 — Sommer Panage • @sommer • Swift Summit 2016
  • 8. Why is GraphQL such a big deal for mobile? 8 — Sommer Panage • @sommer • Swift Summit 2016
  • 9. Let's write an app 9 — Sommer Panage • @sommer • Swift Summit 2016
  • 10. In a REST world, we'd hit this endpoint: http://swapi.co/api/people/1/ And we'd get back... 10 — Sommer Panage • @sommer • Swift Summit 2016
  • 11. { "name": "Luke Skywalker", "height": "1.72 m", "mass": "77 Kg", "hair_color": "Blond", "skin_color": "Caucasian", "eye_color": "Blue", "birth_year": "19 BBY", "gender": "Male", "homeworld": "http://swapi.co/api/planets/1/", "films": [ "http://swapi.co/api/films/1/", "http://swapi.co/api/films/2/", "http://swapi.co/api/films/3/" ], "species": [ "http://swapi.co/api/species/1/" ], "vehicles": [ "http://swapi.co/api/vehicles/14/", "http://swapi.co/api/vehicles/30/" ], "starships": [ "http://swapi.co/api/starships/12/", "http://swapi.co/api/starships/22/" ], "created": "2014-12-09T13:50:51.644000Z", "edited": "2014-12-10T13:52:43.172000Z", "url": "http://swapi.co/api/people/1/", "image_url": "http://static.srcdn.com/wp-content/uploads/luke-skywalker-star-wars-a-new-hope.jpg" } 11 — Sommer Panage • @sommer • Swift Summit 2016
  • 12. And then...we'd make two more calls to... http://swapi.co/api/starships/12/ and http://swapi.co/api/starships/22/ 12 — Sommer Panage • @sommer • Swift Summit 2016
  • 13. { "name": "X-wing", "model": "T-65 X-wing", "manufacturer": "Incom Corporation", "cost_in_credits": "149999", "length": "12.5", "max_atmosphering_speed": "1050", "crew": "1", "passengers": "0", "cargo_capacity": "110", "consumables": "1 week", "hyperdrive_rating": "1.0", "MGLT": "100", "starship_class": "Starfighter", "pilots": [ "http://swapi.co/api/people/1/", "http://swapi.co/api/people/9/", "http://swapi.co/api/people/18/", "http://swapi.co/api/people/19/" ], "films": [ "http://swapi.co/api/films/3/", "http://swapi.co/api/films/2/", "http://swapi.co/api/films/1/" ], "created": "2014-12-12T11:19:05.340000Z", "edited": "2014-12-22T17:35:44.491233Z", "url": "http://swapi.co/api/starships/12/" } 13 — Sommer Panage • @sommer • Swift Summit 2016
  • 14. { "name": "Imperial shuttle", "model": "Lambda-class T-4a shuttle", "manufacturer": "Sienar Fleet Systems", "cost_in_credits": "240000", "length": "20", "max_atmosphering_speed": "850", "crew": "6", "passengers": "20", "cargo_capacity": "80000", "consumables": "2 months", "hyperdrive_rating": "1.0", "MGLT": "50", "starship_class": "Armed government transport", "pilots": [ "http://swapi.co/api/people/1/", "http://swapi.co/api/people/13/", "http://swapi.co/api/people/14/" ], "films": [ "http://swapi.co/api/films/3/", "http://swapi.co/api/films/2/" ], "created": "2014-12-15T13:04:47.235000Z", "edited": "2014-12-22T17:35:44.795405Z", "url": "http://swapi.co/api/starships/22/" } 14 — Sommer Panage • @sommer • Swift Summit 2016
  • 15. That's 3 calls and a whole lot of data for 1 little VC 15 — Sommer Panage • @sommer • Swift Summit 2016
  • 16. Now in GraphQL, instead we'd write the following query: { person(personID: 1) { name, height, mass, hairColor, eyeColor, imageURL, starshipConnection { edges { node { name } } } } } 16 — Sommer Panage • @sommer • Swift Summit 2016
  • 17. And, I'd get back exactly what I wanted! { "data": { "person": { "name": "Luke Skywalker", "height": 172, "mass": 77, "hairColor": "blond", "eyeColor": "blue", "imageURL": "http://static.srcdn.com/wp-content/uploads/luke-skywalker-star-wars-a-new-hope.jpg", "starshipConnection": { "edges": [ { "node": { "name": "X-wing" } }, { "node": { "name": "Imperial shuttle" } } ] } } } } 17 — Sommer Panage • @sommer • Swift Summit 2016
  • 18. So, why is GraphQL such a big deal for mobile? 1. Ask and ye shall receive! 2. Fewer round trips! 3. Less client logic around data! 18 — Sommer Panage • @sommer • Swift Summit 2016
  • 19. Wait just a minute... 19 — Sommer Panage • @sommer • Swift Summit 2016
  • 20. Our Star Wars Character model struct SWCharacter { let name: String let heightInCm: Int let massInKg: Int let hairColorDescriptor: String let skinColorDescriptor: String let eyeColorDescriptor: String let birthYear: StarWarsUniverse.Year let gender: StarWarsUniverse.Gender let homeworld: StarWarsUniverse.Planet let films: [SWFilm] let species: [StarWarsUniverse.Species] let vehicles: [StarWarsUniverse.Vehicle] let starships: [StarWarsUniverse.Starship] let imageURL: URL? } 20 — Sommer Panage • @sommer • Swift Summit 2016
  • 21. Our Star Wars Character model struct SWCharacter { let name: String? let heightInCm: Int? let massInKg: Int? let hairColorDescriptor: String? let skinColorDescriptor: String? let eyeColorDescriptor: String let birthYear: StarWarsUniverse.Year? let gender: StarWarsUniverse.Gender? let homeworld: StarWarsUniverse.Planet? let films: [SWFilm]? let species: [StarWarsUniverse.Species]? let vehicles: [StarWarsUniverse.Vehicle]? let starships: [StarWarsUniverse.Starship]? let imageURL: URL? } 21 — Sommer Panage • @sommer • Swift Summit 2016
  • 22. Swift, No!!!! struct SWCharacter { let name: String? let heightInCm: Int? let massInKg: Int? let hairColorDescriptor: String? let skinColorDescriptor: String? let eyeColorDescriptor: String let birthYear: StarWarsUniverse.Year? let gender: StarWarsUniverse.Gender? let homeworld: StarWarsUniverse.Planet? let films: [SWFilm]? let species: [StarWarsUniverse.Species]? let vehicles: [StarWarsUniverse.Vehicle]? let starships: [StarWarsUniverse.Starship]? let imageURL: URL? } 22 — Sommer Panage • @sommer • Swift Summit 2016
  • 23. 23 — Sommer Panage • @sommer • Swift Summit 2016
  • 24. Let's model the data how we want it, not how it is → 1 View Controller → 1 Query → 1 Data Model 24 — Sommer Panage • @sommer • Swift Summit 2016
  • 25. 25 — Sommer Panage • @sommer • Swift Summit 2016
  • 26. query AllCharacters { allPeople { edges { node { id name homeworld { name } } } } } 26 — Sommer Panage • @sommer • Swift Summit 2016
  • 27. struct AllCharactersData { let people: [Person] struct Person { let id: String let name: String let homeworld: Homeworld struct Homeworld { let name: String } } } 27 — Sommer Panage • @sommer • Swift Summit 2016
  • 28. query Character($id: ID) { person (id: $id) { id height, mass, hairColor, eyeColor, imageURL, starshipConnection { edges { node { name } } } } } 28 — Sommer Panage • @sommer • Swift Summit 2016
  • 29. struct CharacterData { struct Person { let id: String let height: Int let mass: Int let hairColor: String let eyeColor: String let imageURL: URL? let starshipConnect: [Starship] struct Starship { let name: String } } } 29 — Sommer Panage • @sommer • Swift Summit 2016
  • 30. By having query / view- data based models, we no longer need optionals everywhere! 30 — Sommer Panage • @sommer • Swift Summit 2016
  • 31. But our parsing code still looks like... let parsedData = try JSONSerialization.jsonObject(with: data, options: []) as! [String: Any] self.id = parsedData["id"] as! String self.name = parsedData["name"] as! String self.homeworld = Homeworld(dict: parsedData["homeworld"] as! [String : Any]) Ugh! 31 — Sommer Panage • @sommer • Swift Summit 2016
  • 32. Code Gen! 32 — Sommer Panage • @sommer • Swift Summit 2016
  • 33. 33 — Sommer Panage • @sommer • Swift Summit 2016
  • 34. Apollo's iOS GraphQL Client for Swift → Compile-time safety → Inline validation errors for GraphQL → No wasted cycles on query-gen 34 — Sommer Panage • @sommer • Swift Summit 2016
  • 35. What about...? 35 — Sommer Panage • @sommer • Swift Summit 2016
  • 36. Versioning → "Version-Free" → Easy to test for backwards compatability 36 — Sommer Panage • @sommer • Swift Summit 2016
  • 37. Caching 37 — Sommer Panage • @sommer • Swift Summit 2016
  • 38. Simple Caching Query-based, not object based 38 — Sommer Panage • @sommer • Swift Summit 2016
  • 39. Advanced Caching Flattened results, id-record mapped 39 — Sommer Panage • @sommer • Swift Summit 2016
  • 40. Aren't you supposed to use GraphQL with React Native? 40 — Sommer Panage • @sommer • Swift Summit 2016
  • 41. GraphQL + Swift -> GraphQL shines on mobile -> Swift gives us types and compile time safety -> React Native is new and exciting, but that comes with challenges too 41 — Sommer Panage • @sommer • Swift Summit 2016
  • 42. In Conclusion... 42 — Sommer Panage • @sommer • Swift Summit 2016
  • 43. Pros to GraphQL + Swift → Fewer requests for data → Getting the exact data you need → Code gen -> no janky parsing code → Models that are reflective of your views → A strongly typed backend schema 43 — Sommer Panage • @sommer • Swift Summit 2016
  • 44. Cons to GraphQL + Swift → Not a lot of tooling yet → Best practices still emerging → Poorly defined schema becomes a big client problem → Not as good for endpoints requiring heavy logic 44 — Sommer Panage • @sommer • Swift Summit 2016
  • 45. tldr: It's worth it! 45 — Sommer Panage • @sommer • Swift Summit 2016
  • 46. Check out → Apollo iOS Client: Documentation and info on Apollo's awesome Swift iOS GraphQL client → 5 benefits of static GraphQL Queries: Blog post from Apollo → Bringing GraphQL to iOS: Blog post from Apollo → GraphQL First: A better way to build modern apps: Blog post from Apollo 46 — Sommer Panage • @sommer • Swift Summit 2016
  • 47. Check out...con’t → GraphQL for mobile: Blog post from Artsy → Relay: Thinking in GraphQL: Post from FB on Caching 47 — Sommer Panage • @sommer • Swift Summit 2016
  • 48. Thank you!! Come ask me questions about GraphQL + Swift or about Accessibility! 48 — Sommer Panage • @sommer • Swift Summit 2016
  • 49. Credits Images GediminasTurbo Baltaduonis, Danil Polshin, Apple, Facebook, Apollo, Lucasfilm General Chorus Fitness, Apollo, Facebook 49 — Sommer Panage • @sommer • Swift Summit 2016