Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Apollo iOS Workshop - Swift Alps, Crans-Montana...

Apollo iOS Workshop - Swift Alps, Crans-Montana, Switzerland - November 2019

A set of slides from my Swift Alps 2019 workshop on Apollo iOS, featuring our hotttt new in-progress tutorial.

https://www.apollographql.com/docs/ios/tutorial/tutorial-introduction/

Ellen Shapiro

November 29, 2019
Tweet

More Decks by Ellen Shapiro

Other Decks in Technology

Transcript

  1. Apollo iOS Workshop Swift Alps | Crans-Montana, Switzerland | November

    2019 Ellen Shapiro | @DesignatedNerd | apollographql.com
  2. In mathematics, and more specifically in graph theory, a graph

    is a structure amounting to a set of objects in which some pairs of the objects are in some sense "related" https://en.wikipedia.org/wiki/Graph(discretemathematics))
  3. "Within your schema, you define different types of nodes and

    how they connect/relate to one another." https://graphql.org/learn/thinking-in-graphs/
  4. user/1/details { "user": { "id": 1, "firstName": "Ellen", "lastName": "Shapiro",

    "city": "Madison", "state": "Wisconsin", "country": "USA", "profilePicPath": "user/1/profile.jpg" } }
  5. user/1/details { "user": { "id": 1, "firstName": "Ellen", "lastName": "Shapiro",

    "city": "Madison", "state": "Wisconsin", "country": "USA", "profilePicPath": "user/1/profile.jpg" } }
  6. Schema type User { id: ID! firstName: String lastName: String

    profilePicPath: String city: String state: String country: String } This is written in GraphQL's Schema Definition Language
  7. GraphQL Query query UserDetails { user(id: 1) { id firstName

    lastName profilePicPath } } JSON response { "data": { "user": { "id": 1, "firstName": "Ellen", "lastName": "Shapiro", "profilePicPath": "user/1/profile.jpg" } } }
  8. GraphQL Query query UserDetails { user(id: 1) { id firstName

    lastName profilePicPath } } JSON response { "data": { "user": { "id": 1, "firstName": "Ellen", "lastName": "Shapiro", "profilePicPath": "user/1/profile.jpg" } } }
  9. GraphQL Query query UserDetails { user(id: 1) { id firstName

    lastName profilePicPath } } JSON response { "data": { "user": { "id": 1, "firstName": "Ellen", "lastName": "Shapiro", "profilePicPath": "user/1/profile.jpg" } } }
  10. GraphQL Query query UserDetails { user(id: 1) { firstName lastName

    profilePicPath } } JSON response { "data": { "user": { "firstName": "Ellen", "lastName": "Shapiro", "profilePicPath": "user/1/profile.jpg" } } }
  11. Schema type User { id: ID! firstName: String lastName: String

    profilePicPath: String city: String state: String country: String } This is written in GraphQL's Schema Definition Language
  12. Schema type User { id: ID! firstName: String lastName: String

    profilePicPath: String city: String state: String country: String favoriteColor: String } This is written in GraphQL's Schema Definition Language
  13. GraphQL Query query UserDetails { user(id: 1) { firstName lastName

    profilePicPath favoriteColor } } JSON response { "data": { "user": { "firstName": "Ellen", "lastName": "Shapiro", "profilePicPath": "user/1/profile.jpg", "favoriteColor": "0000FF" } } }
  14. Schema type User { id: ID! firstName: String lastName: String

    profilePicPath: String city: String state: String country: String favoriteColor: String } This is written in GraphQL's Schema Definition Language
  15. Schema type User { id: ID! firstName: String lastName: String

    profilePicPath: String city: String state: String country: String favoriteColor: String } This is written in GraphQL's Schema Definition Language
  16. Schema type User { id: ID! // <-- NOT optional

    firstName: String lastName: String profilePicPath: String city: String state: String country: String favoriteColor: String } This is written in GraphQL's Schema Definition Language
  17. Schema type User { id: ID! firstName: String lastName: String

    profilePicPath: String city: String state: String country: String favoriteColor: String } This is written in GraphQL's Schema Definition Language
  18. Schema type User { id: ID! firstName: String // <--

    Optional lastName: String profilePicPath: String city: String state: String country: String favoriteColor: String } This is written in GraphQL's Schema Definition Language
  19. public final class LaunchDetailsQuery: GraphQLQuery { public var id: GraphQLID

    public struct Data: GraphQLSelectionSet { public var launch: Launch? public struct Launch: GraphQLSelectionSet { public var __typename: String public var id: GraphQLID public var site: String? public var mission: Mission? public var rocket: Rocket? public var isBooked: Bool public struct Mission: GraphQLSelectionSet { public var __typename: String public var name: String? public var missionPatch: String? public struct Rocket: GraphQLSelectionSet { public var __typename: String public var name: String? public var type: String? } } } }
  20. public final class LaunchDetailsQuery: GraphQLQuery { public var id: GraphQLID

    public struct Data: GraphQLSelectionSet { public var launch: Launch? public struct Launch: GraphQLSelectionSet { public var __typename: String public var id: GraphQLID public var site: String? public var mission: Mission? public var rocket: Rocket? public var isBooked: Bool public struct Mission: GraphQLSelectionSet { public var __typename: String public var name: String? public var missionPatch: String? } public struct Rocket: GraphQLSelectionSet { public var __typename: String public var name: String? public var type: String? } } } }
  21. public final class LaunchDetailsQuery: GraphQLQuery { public var id: GraphQLID

    public struct Data: GraphQLSelectionSet { public var launch: Launch? public struct Launch: GraphQLSelectionSet { public var __typename: String public var id: GraphQLID public var site: String? public var mission: Mission? public var rocket: Rocket? public var isBooked: Bool public struct Mission: GraphQLSelectionSet { public var __typename: String public var name: String? public var missionPatch: String? } public struct Rocket: GraphQLSelectionSet { public var __typename: String public var name: String? public var type: String? } } } }
  22. public final class LaunchDetailsQuery: GraphQLQuery { public var id: GraphQLID

    public struct Data: GraphQLSelectionSet { public var launch: Launch? public struct Launch: GraphQLSelectionSet { public var __typename: String public var id: GraphQLID public var site: String? public var mission: Mission? public var rocket: Rocket? public var isBooked: Bool public struct Mission: GraphQLSelectionSet { public var __typename: String public var name: String? public var missionPatch: String? } public struct Rocket: GraphQLSelectionSet { public var __typename: String public var name: String? public var type: String? } } } }
  23. public final class LaunchDetailsQuery: GraphQLQuery { public var id: GraphQLID

    public struct Data: GraphQLSelectionSet { public var launch: Launch? public struct Launch: GraphQLSelectionSet { public var __typename: String public var id: GraphQLID public var site: String? public var mission: Mission? public var rocket: Rocket? public var isBooked: Bool public struct Mission: GraphQLSelectionSet { public var __typename: String public var name: String? public var missionPatch: String? } public struct Rocket: GraphQLSelectionSet { public var __typename: String public var name: String? public var type: String? } } } }
  24. type User { id: ID! firstName: String lastName: String profilePicPath:

    String city: String state: String country: String favoriteColor: String }