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

GraphQL From The Ground Up - Apollo Mobile Day,...

GraphQL From The Ground Up - Apollo Mobile Day, Online, January 2021

Video: Coming soon!

Abstract: You've heard a lot of people talking about GraphQL lately, but what IS it? What are the problems it's supposed to be solving - and what are the problems it's _not_ supposed to be solving? How can you use it to improve your mobile development process? Ellen Shapiro, who maintains the Apollo GraphQL iOS SDK, will help untangle all this and more.

Ellen Shapiro

January 26, 2021
Tweet

More Decks by Ellen Shapiro

Other Decks in Technology

Transcript

  1. GRAPHQL FROM THE GROUND UP APOLLO MOBILE DAY | THE

    INTERNETS | JANUARY 2021 ELLEN SHAPIRO | @DESIGNATEDNERD | APOLLOGRAPHQL.COM
  2. In computer science, graphs are used to represent networks of

    communication, data organization, computational devices, the flow of computation, etc. https://en.wikipedia.org/wiki/Graph_theory#Computer_science
  3. !

  4. !

  5. public final class LaunchInfoQuery: GraphQLQuery { public init(id: GraphQLID) {

    self.id = id } public struct Data: GraphQLSelectionSet { public var launch: Launch? { public struct Launch: GraphQLSelectionSet { public var site: String? public var mission: Mission? public var rocket: Rocket? public struct Mission: GraphQLSelectionSet { public var name: String? } public struct Rocket: GraphQLSelectionSet { public var name: String? } } } }
  6. public final class LaunchInfoQuery: GraphQLQuery { public init(id: GraphQLID) {

    self.id = id } public struct Data: GraphQLSelectionSet { public var launch: Launch? { public struct Launch: GraphQLSelectionSet { public var site: String? public var mission: Mission? public var rocket: Rocket? public struct Mission: GraphQLSelectionSet { public var name: String? } public struct Rocket: GraphQLSelectionSet { public var name: String? } } } }
  7. public final class LaunchInfoQuery: GraphQLQuery { public init(id: GraphQLID) {

    self.id = id } public struct Data: GraphQLSelectionSet { public var launch: Launch? { public struct Launch: GraphQLSelectionSet { public var site: String? public var mission: Mission? public var rocket: Rocket? public struct Mission: GraphQLSelectionSet { public var name: String? } public struct Rocket: GraphQLSelectionSet { public var name: String? } } } }
  8. public final class LaunchInfoQuery: GraphQLQuery { public init(id: GraphQLID) {

    self.id = id } public struct Data: GraphQLSelectionSet { public var launch: Launch? { public struct Launch: GraphQLSelectionSet { public var site: String? public var mission: Mission? public var rocket: Rocket? public struct Mission: GraphQLSelectionSet { public var name: String? } public struct Rocket: GraphQLSelectionSet { public var name: String? } } } }
  9. public final class LaunchInfoQuery: GraphQLQuery { public init(id: GraphQLID) {

    self.id = id } public struct Data: GraphQLSelectionSet { public var launch: Launch? { public struct Launch: GraphQLSelectionSet { public var site: String? public var mission: Mission? public var rocket: Rocket? public struct Mission: GraphQLSelectionSet { public var name: String? } public struct Rocket: GraphQLSelectionSet { public var name: String? } } } }
  10. public final class LaunchInfoQuery: GraphQLQuery { public init(id: GraphQLID) {

    self.id = id } public struct Data: GraphQLSelectionSet { public var launch: Launch? { public struct Launch: GraphQLSelectionSet { public var site: String? public var mission: Mission? public var rocket: Rocket? public struct Mission: GraphQLSelectionSet { public var name: String? } public struct Rocket: GraphQLSelectionSet { public var name: String? } } } }
  11. apolloClient.fetch(query: LaunchInfoQuery(id: "80")) { result in switch result { case

    .failure(let error): print("Error: \(error)") case .success(let graphQLResult): if let errors = graphQLResult.errors { print("Errors: \(errors)") } if let missionName = graphQLData?.data?.launch?.mission?.name { print("Mission name: \(String(describing: missionName)") } } }
  12. apolloClient.fetch(query: LaunchInfoQuery(id: "80")) { result in switch result { case

    .failure(let error): print("Error: \(error)") case .success(let graphQLResult): if let errors = graphQLResult.errors { print("Errors: \(errors)") } if let missionName = graphQLData?.data?.launch?.mission?.name { print("Mission name: \(String(describing: missionName)") } } }
  13. apolloClient.fetch(query: LaunchInfoQuery(id: "80")) { result in switch result { case

    .failure(let error): print("Error: \(error)") case .success(let graphQLResult): if let errors = graphQLResult.errors { print("Errors: \(errors)") } if let missionName = graphQLData?.data?.launch?.mission?.name { print("Mission name: \(String(describing: missionName)") } } }
  14. apolloClient.fetch(query: LaunchInfoQuery(id: "80")) { result in switch result { case

    .failure(let error): print("Error: \(error)") case .success(let graphQLResult): if let errors = graphQLResult.errors { print("Errors: \(errors)") } if let missionName = graphQLData?.data?.launch?.mission?.name { print("Mission name: \(missionName) } } }
  15. apolloClient.fetch(query: LaunchInfoQuery(id: "80")) { result in switch result { case

    .failure(let error): print("Error: \(error)") case .success(let graphQLResult): if let errors = graphQLResult.errors { print("Errors: \(errors)") } if let missionName = graphQLData?.data?.launch?.mission?.name { print("Mission name: \(missionName) } } }
  16. apolloClient.fetch(query: LaunchInfoQuery(id: "80")) { result in switch result { case

    .failure(let error): print("Error: \(error)") case .success(let graphQLResult): if let errors = graphQLResult.errors { print("Errors: \(errors)") } if let missionName = graphQLData?.data?.launch?.mission?.name { print("Mission name: \(missionName) } } }
  17. A REST PLAY Me: Can we add this field that's

    on endpoint A to endpoint B? Backend: Sure, we'll put it in the backlog.
  18. BETTER GRAPHQL UPLOADS 1. Upload to something that returns a

    URL 2. Send the URL to your graph using GraphQL
  19. BETTER GRAPHQL UPLOADS 1. Upload to something that returns a

    URL 2. Send the URL to your graph using GraphQL 3. Tear out way less hair than trying to upload with GQL
  20. OBLIGATORY SUMMARY SLIDE ▸ A Graph is a way of

    conceptualizing data based on pieces of data (nodes) and the ways those pieces are connected (edges).
  21. OBLIGATORY SUMMARY SLIDE ▸ A Graph is a way of

    conceptualizing data based on pieces of data (nodes) and the ways those pieces are connected (edges). ▸ GraphQL is a way of querying your data and how it's connected
  22. OBLIGATORY SUMMARY SLIDE ▸ A Graph is a way of

    conceptualizing data based on pieces of data (nodes) and the ways those pieces are connected (edges). ▸ GraphQL is a way of querying your data and how it's connected ▸ The Schema defines what you can ask for (with types!)
  23. OBLIGATORY SUMMARY SLIDE ▸ A Graph is a way of

    conceptualizing data based on pieces of data (nodes) and the ways those pieces are connected (edges). ▸ GraphQL is a way of querying your data and how it's connected ▸ The Schema defines what you can ask for (with types!) ▸ Operations let you ask for and receive only the data you want
  24. OBLIGATORY SUMMARY SLIDE ▸ A Graph is a way of

    conceptualizing data based on pieces of data (nodes) and the ways those pieces are connected (edges). ▸ GraphQL is a way of querying your data and how it's connected ▸ The Schema defines what you can ask for (with types!) ▸ Operations let you ask for and receive only the data you want ▸ GraphQL is a real cool hammer - not every problem is a nail