Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

apollographql/frontpage-ios-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

47 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Apollo iOS Hello World app

DEPRECATION NOTICE

This sample is deprecated as of September 2020.

Please see the current Apollo iOS Tutorial for the most recent sample app that uses all the new shiny.

Olde Instructions:

This is a simple example Apollo iOS app.

Installation

This project requires the latest version of Xcode, which you can install from the Mac App Store.

To clone the Git repository to your local machine, including submodules:

git clone --recursive https://github.com/apollographql/frontpage-ios-app.git

Dependencies

Make sure you have CocoaPods installed and then run:

pod install

Server

This app talks to the frontpage example server, available here: https://github.com/apollographql/frontpage-server. Follow the instructions there and start the server before running the iOS app. (You can find the equivalent React app here if you want to run them side by side.)

Starting the app

You can then open FrontPage.xcworkspace and press the run button to run the app. It should load a list of posts and display their titles, authors and number of votes in a table view. You can also upvote posts.

If you want to run on a device, change localhost to your machine's local IP address in AppDelegate.swift.

This is a very basic app, but it does demonstrate how you can hook up GraphQL query results to your UI. The code in PostListViewController.swift fetches data based on a GraphQL query defined in PostListViewController.graphql. That query refers to a fragment defined in PostTableViewCell.graphql, which nicely illustrates how you can describe your data needs next to the UI component that uses them.

Building the target will run apollo-codegen against all .graphql files in your project and generate query-specific result types in API.swift.

Try commenting out (GraphQL uses # for comments) a post's title and rebuild the target. You should get a compile-time error because the code in our view controller accesses post.title. The type system guarantees at compile-time that the data we access from our code is actually specified as part of the query.

apollo-codegen also validates GraphQL query documents against the schema, and Xcode will show validation errors inline. Try adding an email field under author for instance, and rebuild to show the errors.

Xcode

About

๐Ÿ“„ Apollo "hello world" app, for iOS

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published