Git Product home page Git Product logo

frontpage-ios-app's Introduction

Apollo iOS Hello World app

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

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

frontpage-ios-app's People

Contributors

martijnwalraven avatar wingchi avatar zol avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.