Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GraphQL Intro iOS
Search
Sergey Nikolaev
August 07, 2019
Programming
0
33
GraphQL Intro iOS
Sergey Nikolaev
August 07, 2019
Tweet
Share
Other Decks in Programming
See All in Programming
Understanding Ast By Looking
inouehi
0
120
object-oriented-conference-2024
fuwasegu
6
1.9k
チームでモデリングを育てるうえで 考えたこと・気づいたこと / Cultivating Modeling in Teams: Thoughts and Insights
mackey0225
5
2.4k
PHPerKaigi 2024〜10年以上動いているレガシーなバッチシステムを Kubernetes(Amazon EKS) に移行する取り組み〜
tshinowpub
1
220
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
510
The Future of C++ Interoperability: Insights from Porting a Game to Swift
teamhimeh
0
280
Material 3で Material 2ぽい見た目にする
numeroanddev
2
250
SwiftUI, Jetpack Composeの導入で変化した「家族アルバム みてね」のアプリ開発体験
hicka04
6
400
App Router への移行は「改善」となり得るのか?/ Can migration to App Router be an improvement
takefumiyoshii
1
130
孤独のCTOグルメという やや奇抜な企画をやった目的と効果
shoheimitani
3
1k
ONE WEDGE_Company_Information
1wedge
0
180
Dockerで始めるAWS Lambda開発
stutkhd0709
14
2.5k
Featured
See All Featured
Designing with Data
zakiwarfel
94
4.8k
Code Review Best Practice
trishagee
54
15k
Done Done
chrislema
178
15k
We Have a Design System, Now What?
morganepeng
42
6.7k
How GitHub Uses GitHub to Build GitHub
holman
467
290k
A designer walks into a library…
pauljervisheath
199
23k
From Idea to $5000 a Month in 5 Months
shpigford
376
45k
Documentation Writing (for coders)
carmenintech
59
3.8k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
18
6.8k
The Mythical Team-Month
searls
214
42k
Design by the Numbers
sachag
274
18k
Fantastic passwords and where to find them - at NoRuKo
philnash
35
2.4k
Transcript
GraphQL Intro
https://domain/posts/{id}
None
Schema
Schema "kind": "OBJECT", "name": "Product", "description": "", "fields": [ {
"name": "id", "description": "", "args": [], "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "SCALAR", "name": "ID", "ofType": null } }, "isDeprecated": false, "deprecationReason": null }
Schema "name": "suggestedProducts", "description": "", "args": [], "type": { "kind":
"NON_NULL", "name": null, "ofType": { "kind": "LIST", "name": null, "ofType": { "kind": "INTERFACE", "name": "ProductInterface", "ofType": null } } }, "isDeprecated": false, "deprecationReason": null
Schema "kind": "OBJECT", "name": "Query", "description": "", "fields": [ {
"name": "product", "description": "", "args": [ { "name": "id", "description": "", "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "SCALAR", "name": "ID", "ofType": null } }, "defaultValue": null } ], } ]
Request query GetDetailFragmentProduct($id: ID!) { product(id: $id) { ... ProductFragment
suggestedProducts { ... ProductFragment ... on RelatedProduct { commonTags } ... on PromotionalProduct { discount } } } user { discount age } } fragment ProductDetails on ProductInterface { id name description price(currency: "USD") }
API.swift public final class GetFragmentProductQuery: GraphQLQuery { public let operationDefinition
= "query GetFragmentProduct($id: ID!) {\n product(id: $id) {\n __typename\n ...ProductFragment\n suggestedProducts {\n __typename\n ...ProductFragment\n }\n }\n}" public var queryDocument: String { return operationDefinition.appending(ProductFragment.fragmentDefinition) } public var id: GraphQLID public init(id: GraphQLID) { self.id = id } public var variables: GraphQLMap? { return ["id": id] } public struct Data: GraphQLSelectionSet { public static let possibleTypes = ["Query"] public static let selections: [GraphQLSelection] = [ GraphQLField("product", arguments: ["id": GraphQLVariable("id")], type: .object(Product.selections)), ] public private(set) var resultMap: ResultMap public init(unsafeResultMap: ResultMap) { self.resultMap = unsafeResultMap } public init(product: Product? = nil) { self.init(unsafeResultMap: ["__typename": "Query", "product": product.flatMap { (value: Product) -> ResultMap in value.resultMap }]) } public var product: Product? { get { return (resultMap["product"] as? ResultMap).flatMap { Product(unsafeResultMap: $0) } } set { resultMap.updateValue(newValue?.resultMap, forKey: "product") } }
Request body hashing
Batching
Cache
Cache
Cache
Cache
Cache
None
https://epa.ms/graphql-ios-intro Sources and demo projects