Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GraphQL client libraries for iOS

Tags:

I have a GraphQL service that I need to hit from an iOS app, and I'm trying to survey what my options are for client libraries geared towards this purpose. My initial impression is that there are not many good options out there, and I'm a little surprised by this since Facebook's mobile app is always cited among the motivational material for GraphQL itself.

What follows is my current understanding of my options. My questions is: what client library options am I overlooking? I'm also curious if you were to imagine the ideal GraphQL client library for iOS, what might it look like?

  1. Just Alamofire, AFNetworking, or NSURLSession directly, passing in lovingly hand-crafted Query Documents and spelunking through a Dictionary representing the resulting JSON, or
  2. Chester
  3. GraphQLicious
  4. Swift-GraphQL
like image 352
pohl Avatar asked Apr 21 '16 15:04

pohl


People also ask

Does Apple use GraphQL?

Apollo iOS is an open-source GraphQL client for native iOS apps, written in Swift. It enables you to execute queries and mutations against a GraphQL server and returns results as operation-specific Swift types.

Do you need Apollo for GraphQL?

But GraphQL is just a query language. And in order to use it easily, we need to use a platform that will do all the heavy lifting for us. One such platform is provided by Apollo. The Apollo platform is an implementation of GraphQL that can transfer data between the cloud (server) to the UI of your app .


2 Answers

This question was asked a long time ago - I think today the standard answer to this will be to use Apollo Client.

It uses a similar API as the Apollo Client on the web and has a couple of really nice features:

  • Static type generation based on GraphQL Queries & Mutations
  • Normalized cache
  • Query watching & automatic UI updates
  • Manual store updates

It has not yet reached 1.0 but overall is a super promising project!

Here are some resources that should help you get started:

  • Apollo iOS Quickstart
  • Apollo iOS on GitHub
  • Ray Wenderlich GraphQL Tutorial
  • Learn Apollo iOS Track
like image 100
nburk Avatar answered Oct 23 '22 04:10

nburk


I would not build queries by hand, and I think both Chester and GraphQLicious would be fine for you. If I had to imagine the perfect library, it should not only build queries but also parse the result into Swift objects. This, as you may know from JSON parsing libraries, is not a small task and that's why most of the GraphQL-Builder libraries don't do it.

Disclosure: I'm one of the guys behind GraphQLicious

like image 30
Vik Avatar answered Oct 23 '22 05:10

Vik