Skip to content

michaelnisi/swifters

Repository files navigation

Swifters

The Swifters iOS app lets you browse Swift users on GitHub. Its purpose is to explore GraphQL with Apollo iOS, a strongly-typed, caching GraphQL client. Swifters queries GitHub’s GraphQL API v4. If your new to GraphQL, you might want to read my introduction.

The Swifters iOS app lets you browse Swift users on GitHub. Its purpose is to explore GraphQL with Apollo iOS, a strongly-typed, caching GraphQL client. Swifters queries GitHub’s GraphQL API v4.

Screenshot 1 Screenshot 2

Swifters progressively populates its cache, while users scroll a list of Swift developers on GitHub, loading two to three handfuls of Swifters at a time. Tapping a developer in the list shows details.

Objectives

Dependencies

  • Apollo iOS – A strongly-typed, caching GraphQL client
  • DeepDiff – Amazingly incredible extraordinary lightning fast diffing
  • Nuke – Image loading and caching
  • Ola – Check reachability of host

Installation

Accessing GitHub

Swifters needs a personal access token to communicate with GitHub’s GraphQL server.

These scopes are required:

  • read:user
  • user:email

Preparing the Workspace

$ GITHUB_TOKEN=<token> make

What this does

  • Clone repositories of framework dependencies into ./deps
  • Generate ./apollo.config.js with your GitHub token
  • Copy ./apollo.config.js to ./Swifters/github/apollo.config.json

Running the app

$ open Swifters.xcworkspace
  • Select Swifters scheme
  • Run ⌘R

🙌

Onwards

If you want to modify GraphQL queries to develop this app further, you need code generation tooling. Apollo GraphQL tools are written in TypeScript and run on Node.js.

Apollo CLI

$ npm i -g apollo

Generating Swift files from GraphQL queries

After you have adjusted *.graphql queries to your needs, you must generate the GraphQL related Swift source files. Apollo recommends adding a Run Script Phase to your Xcode target, but I find using the command line interface directly less opaque.

$ apollo client:codegen --target=swift ./Swifters/github

License

MIT License