Slide 1

Slide 1 text

@redryerye ࠷దͳiOSͷ GraphQLΫϥΠΞϯτΛٻΊͯ Finding alternatives for GraphQL client for iOS

Slide 2

Slide 2 text

Yuki Yamamoto @redryerye iOS Engineer @

Slide 3

Slide 3 text

Last year, my team decided to use GraphQL for our new feature 🏃

Slide 4

Slide 4 text

A new co-working space has opened in Shimokitazawa GraphQL is used in the new seat reservation featur e (Both iOS/Android)

Slide 5

Slide 5 text

GraphQL is used

Slide 6

Slide 6 text

GraphQL is used with apollo-ios

Slide 7

Slide 7 text

GraphQL is used with apollo-ios

Slide 8

Slide 8 text

About apollo-ios • The most popular open-sourced GraphQL client library for iOS

Slide 9

Slide 9 text

About apollo-ios • The most popular open-sourced GraphQL client library for iOS • Used in production by many companies around the world Github uses Apollo client potatotips #61

Slide 10

Slide 10 text

Apollo is great!

Slide 11

Slide 11 text

But it can be a hassle 🧐

Slide 12

Slide 12 text

• Explaining the hurdle I had in using Apollo Today, I will be..

Slide 13

Slide 13 text

Today, I will be.. • Explaining the hurdle I had in using Apollo • Looking at other alternatives

Slide 14

Slide 14 text

Today, I will be.. • Explaining the hurdle I had in using Apollo • Looking at other alternatives New to GraphQL? The details of GraphQL will not be covered here. However, you will probably able to understand this talk since I will be explaining about the implementation one by one 😉

Slide 15

Slide 15 text

Apollo iOS: Things I like about it

Slide 16

Slide 16 text

Apollo iOS: Things I like about it 1. Strong community 2. Guarantees compile time type safety

Slide 17

Slide 17 text

Apollo iOS: Things I like about it 1. Strong community 2. Guarantees compile time type safety

Slide 18

Slide 18 text

Apollo iOS has a strong community • Actively maintained by Apollo, which is a GraphQL focused company

Slide 19

Slide 19 text

• Actively maintained by Apollo, which is a GraphQL focused company Had seen an amazing work done in the community by the team, especially by Ellen 😭 Apollo iOS has a strong community

Slide 20

Slide 20 text

• Actively maintained by Apollo, which is a GraphQL focused company • Easy to fi nd resources about the library Apollo iOS has a strong community

Slide 21

Slide 21 text

Apollo iOS: Things I like about it 1. Strong community 2. Guarantees compile time type safety

Slide 22

Slide 22 text

Apollo iOS: Things I like about it 1. Strong community 2. Guarantees compile time type safety

Slide 23

Slide 23 text

What does this mean? 🤔

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Queries are fl exible

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Query-speci fi c nested structs will be generated ✅ Compile time safety

Slide 31

Slide 31 text

Queries are fl exible

Slide 32

Slide 32 text

Queries are fl exible name name name PersonCell CharacterList Tie a query to a view = View : Query or Fragment (Works well with SwiftUI)

Slide 33

Slide 33 text

name name name PersonCell CharacterList But this did not suit our case

Slide 34

Slide 34 text

name name name PersonCell CharacterList 👆 Check this out for the details

Slide 35

Slide 35 text

What’s the struggle? 🤔

Slide 36

Slide 36 text

• Dealing with nested structs can be a hassle especially when passing it to your domain layer Apollo iOS: The Struggle

Slide 37

Slide 37 text

Generated structs are nested based on a query Apollo iOS: The Struggle

Slide 38

Slide 38 text

Generated structs are nested based on a query The more query gets complicated, so does the structs. Apollo iOS: The Struggle

Slide 39

Slide 39 text

Generated structs are nested based on a query Generated structs does not conform to the Equatable protocol Apollo iOS: The Struggle 👆

Slide 40

Slide 40 text

I wish I could easily map to domain objects a little more…

Slide 41

Slide 41 text

It’s always an option • Not to use a client library and write your own client • Utilize Fragment

Slide 42

Slide 42 text

Any alternative?

Slide 43

Slide 43 text

Yes. graphql.org/code

Slide 44

Slide 44 text

Yes. Graphaello will not be covered here since it focuses on SwiftUI graphql.org/code 👉

Slide 45

Slide 45 text

Let’s look at SwiftGraphQL graphql.org/code 👉

Slide 46

Slide 46 text

Apollo iOS

Slide 47

Slide 47 text

Apollo iOS

Slide 48

Slide 48 text

Apollo iOS

Slide 49

Slide 49 text

SwiftGraphQL

Slide 50

Slide 50 text

SwiftGraphQL

Slide 51

Slide 51 text

SwiftGraphQL

Slide 52

Slide 52 text

SwiftGraphQL

Slide 53

Slide 53 text

SwiftGraphQL

Slide 54

Slide 54 text

Looks good for mapping to models!

Slide 55

Slide 55 text

Comparing apollo-ios and SwiftGraphQL

Slide 56

Slide 56 text

Comparing apollo-ios and SwiftGraphQL

Slide 57

Slide 57 text

Comparing apollo-ios and SwiftGraphQL

Slide 58

Slide 58 text

Summary • Mapping generated structs to domain objects can be a hassle • Other GraphQL clients can be your solution depending on your situation

Slide 59

Slide 59 text

developers.kankak.com I will post my update on the blog

Slide 60

Slide 60 text

Thank you!

Slide 61

Slide 61 text

Resources • https://www.apollographql.com/docs/ios/ • https://www.apollographql.com/blog/community/bringing-graphql-to-ios- fc46423befa1/#generating-native-result-types • https://miyashi.app/post/graphql-impressions/ • https://speakerdeck.com/sonatard/swiftui-graphql • https://www.the-guild.dev/blog/swift-graphql? utm_content=175727619&utm_medium=social&utm_source=twitter&hss_cha nnel=tw-1141026790653059072