-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added iOS Track for learnapollo #38
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing tutorial!
Hope the suggestions are clear.
Other general suggestions:
required
is GraphQL lingo for mandatory, please update the uses of mandatory accordingly- the gap between text and code snippets seems to be too wide at some parts, meaning that you describe necessary code changes but don't provide the according code snippet. This makes it difficult to even know wherr the code should be put, let alone what exactly you are supposed to do. my experience is that it's probably better to err on the side of holding hands too much rather than too little when it comes to code snippets. interested to hear your opinion on this one.
- in the same vein, please make sure to update code snippets that are supposed to be copied with the ```swift@path syntax. Snippets that are not supposed to be copied don't need the @path part
content/tutorial-ios/ios-01.md
Outdated
|
||
Then add the following two lines after the import statements: | ||
|
||
```swift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ```swift@path/to/file syntax to enable copy button for snippets that the reader should copy and paste in his code (see React or RN tracks for example)
This is the 2nd exercise in the **iOS Track** of this Apollo Client Tutorial! | ||
|
||
## Goal | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pokedex: -> pokedex.
|
||
This query will return the `id` and the `name` of the `Trainer` that is called `__NAME__`. | ||
|
||
> Note: You can copy this query directly into the [GraphiQL](https://api.graph.cool/simple/v1/__PROJECT_ID__) playground and inspect the results there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refer to the built in GraphiQL rather than the URL
content/tutorial-ios/ios-02.md
Outdated
default: | ||
fatalError("ERROR: Unknown section") | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} missing?
content/tutorial-ios/ios-03.md
Outdated
|
||
## Introduction | ||
|
||
Open the directory that contains the 3rd exercise (`exercise-03`) and open `pokedex-apollo.xcworkspace`. It already contains a running version of the code you wrote in the previous lesson. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the React track it's not always the case that exercise-n+1 starts right where exercise-n ended. Especially "wiring up" things like import statements and setting up new routes to the router have been added to allow the reader to focus on the Apollo-specific tasks. Might be worth to consider a similar approach for the iOS track. Just thought I mentioned it, it's not mandatory :)
content/tutorial-ios/ios-06.md
Outdated
} | ||
``` | ||
|
||
That's a lot of of code, let's try to understand what it does! In the very beginning, we check if we're currently in the _editing state_ - if that is the case we are going to perform the mutation using the strings that are written in the text fields. Therefore, we first make sure that the required data is provided using a `guard` statement. We then start the activity indicator to indicate to the user that a network request has started. Finally, we instantiate the `UpdatePokemonMutation` that was generated by `apollo-codegen` based on the mutation we added in `PokemonDetailViewController.graphql`. Subsequently, we call `perform` on our `ApolloClient` instance passing the instance of the mutation as well as a callback to deal with the return value. Since we are using our `PokemonDetails` fragment again, we can simply extract this from the return value inside the callback and assign it the `pokemonDetails` property. This will automatically update the UI because of the `didSet` property observer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a lot of of -> a lot of
content/tutorial-ios/ios-06.md
Outdated
|
||
### Updating The UI | ||
|
||
That is because the data in the `ownedPokemons` array in `PokedexTableViewController` is independent from the data we just updated in `PokemonDetailViewController`, so we have to manually update it. Let's do so again with a closure. Add the following property to `PokemonDetailViewController`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think wording can be improved here. The data is not unrelated (it's supposed to be the same!) it's just that Apollo doesn't know that - how would it?
content/tutorial-ios/ios-06.md
Outdated
## Recap | ||
|
||
Congratulations, you have implemented the last bit of functionality for this tutorial! 🚀 Let's recap what we learned in this lesson: | ||
- Mutations for updating and deleting existing data entries are syntactially similar to mutations for adding new data entries as well to queries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve wording
content/tutorial-ios/ios-06.md
Outdated
|
||
Congratulations, you have implemented the last bit of functionality for this tutorial! 🚀 Let's recap what we learned in this lesson: | ||
- Mutations for updating and deleting existing data entries are syntactially similar to mutations for adding new data entries as well to queries | ||
- The result of a mutation can contain any data that we specify - we can conveniently this data to update the UI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve wording
src/utils/content.ts
Outdated
@@ -110,6 +110,25 @@ export const chapters: Chapter[] = [ | |||
title: '05 - Basic Mutations', | |||
alias: 'rne-05', | |||
}]), | |||
new Chapter('iOS', 'tutorial-ios', true, 'Learn how to easily get started iOS and GrahQL with Apollo Client. You will use the prepared application as a playground to experiment with an iOS Pokedex App.', [{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to reflect that the track is more than a playground. check other texts for comparison
|
||
The **Apollo iOS client** can be installed through Cocoapods or Carthage. Since we are using Cocoapods in this project, go ahead and open the `Podfile` and add the following line: | ||
|
||
```ruby |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```sh?
|
||
## Introduction | ||
|
||
Sign up with GitHub to receive your own `pokedex-apollo` project here: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be consistent with your usage of pokedex-ios
, pokedex-apollo
, apollo-pokedex
.
content/tutorial-ios/ios-04.md
Outdated
|
||
Welcome to the 4th exercise in the **iOS Track** of this Apollo Client Tutorial! | ||
|
||
|
||
## Goal | ||
|
||
In this exercise, our **goal** is to add new Pokemons to the Pokedex. Therefore, we are going to learn about _mutations_. | ||
In this exercise, our **goal** is to display a _detail view_ for a Pokemon when the user selects it in the table view. Therefore, we are going to learn about a new GraphQL feature that allow to reuse sub-parts of a query: Fragments! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that allows us
content/tutorial-ios/ios-04.md
Outdated
|
||
With the new `PokemonDetailViewController` we now have have two differents areas in our app where we need to access a Pokemon's `name` and `url` (the `PokemonCell` is the second one). Currently, the only way for us to do so is by using the generated struct `TrainerQuery.Data.Trainer.OwnedPokemon` in both places. However, with this approach we are coupling the data requirements of the `PokemonCell` very tightly to the ones of our `PokemonDetailViewController`. This might turn out very inconvenient when our data requirements change in the future and suddenly one area should include more, less or complemetely different data. Fragments enable independent usage of the same data in various locations, which decouples the data requirements of different views and greatly improves our flexibility! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
complemetely
} | ||
``` | ||
|
||
Since we don't actually set the `pokemonDetails` property yet, but try to access it, the app will crash if you test this feature now. This is because the property is declared as an implicitly unwrapped optional! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implicitely
content/tutorial-ios/ios-04.md
Outdated
|
||
In this lesson, we learned about using fragments and why they are essential for using the **Apollo iOS client**. Let's revisit the key learning of this exercise: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key learnings
content/tutorial-ios/ios-05.md
Outdated
@@ -1,224 +1,189 @@ | |||
# Tutorial 05 - Fragments | |||
# Basic Mutations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tutorial 05 - Basic Mutations
content/tutorial-ios/ios-05.md
Outdated
|
||
Run the app and tap on a Pokemon in your Pokedex, the `PokemonDetailViewController` should now display the image, name and url of the Pokemon you selected. | ||
In this exercise, we added functionality to our app that allows to add a new Pokemon to our Pokedex and take advantage of the caching and automatic UI updates that's implementing in the **Apollo iOS client**. Here is a summary of what we learned: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's implemented
No description provided.