Slide 1

Slide 1 text

SERVER-SIDE SWIFT AND GRAPHQL: A MATCH MADE IN ! HEAVEN OR HELL ? DEEP DISH SWIFT | CHICAGO, IL | MAY 2023 ELLEN SHAPIRO | MASTODON.SOCIAL/@DESIGNATEDNERD | PIXITEAPPS.COM

Slide 2

Slide 2 text

FULL ! DISCLOSURE @[email protected]

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

https://www.flickr.com/photos/fwooper7/9650957891

Slide 6

Slide 6 text

SOME DEFINITIONS @[email protected]

Slide 7

Slide 7 text

"Docker is a container virtualization platform that builds on tools like Virtual Box!" @[email protected]

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

SOME BASIC DEFINITIONS @[email protected]

Slide 10

Slide 10 text

SOME BASIC DEFINITIONS FOR A LOT OF APPS @[email protected]

Slide 11

Slide 11 text

YOUR APP'S DATA @[email protected]

Slide 12

Slide 12 text

YOUR APP'S DATA THE INFORMATION YOU WANT TO STORE, MANIPULATE AND/OR DISPLAY @[email protected]

Slide 13

Slide 13 text

THE SERVER @[email protected]

Slide 14

Slide 14 text

THE SERVER THE PLACE WHERE THE CANONICAL VERSION OF YOUR DATA LIVES @[email protected]

Slide 15

Slide 15 text

THE SERVER THE PLACE WHERE THE CANONICAL VERSION OF YOUR DATA LIVES (Eventually)

Slide 16

Slide 16 text

THE SERVER > Some way to store data @[email protected]

Slide 17

Slide 17 text

THE SERVER > Some way to store data > Some way to fetch data from storage @[email protected]

Slide 18

Slide 18 text

THE SERVER > Some way to store data > Some way to fetch data from storage > Some way to receive requests for data @[email protected]

Slide 19

Slide 19 text

THE SERVER > Some way to store data > Some way to fetch data from storage > Some way to receive requests for data > Some way to return responses for requested data @[email protected]

Slide 20

Slide 20 text

THE SERVER > Some way to store data > Some way to fetch data from storage > Some way to receive requests for data > Some way to return responses for requested data > Some security mechanisms @[email protected]

Slide 21

Slide 21 text

THE SERVER @[email protected]

Slide 22

Slide 22 text

SERVER-SIDE SWIFT @[email protected]

Slide 23

Slide 23 text

SERVER-SIDE SWIFT INFRASTRUCTURE TO BUILD AND RUN THE SERVER IN SWIFT @[email protected]

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Slide 26

Slide 26 text

VAPOR A SWIFT LIBRARY FOR RUNNING YOUR SERVER @[email protected]

Slide 27

Slide 27 text

Slide 28

Slide 28 text

FLUENT A SWIFT ADAPTER FOR TALKING TO MULTIPLE DATA STORAGE TYPES @[email protected]

Slide 29

Slide 29 text

THE SERVER > Some way to store data > Some way to fetch data from storage > Some way to receive requests for data > Some way to return responses for requested data > Some security mechanisms @[email protected]

Slide 30

Slide 30 text

THE SERVER > Some way to store data (Fluent) > Some way to fetch data from storage (Fluent) > Some way to receive requests for data > Some way to return responses for requested data > Some security mechanisms @[email protected]

Slide 31

Slide 31 text

THE SERVER > Some way to store data (Fluent) > Some way to fetch data from storage (Fluent) > Some way to receive requests for data (Vapor) > Some way to return responses for requested data (Vapor) > Some security mechanisms (mostly Vapor) @[email protected]

Slide 32

Slide 32 text

A CLIENT @[email protected]

Slide 33

Slide 33 text

A CLIENT A THING THAT INTERACTS WITH DATA FROM YOUR SERVER @[email protected]

Slide 34

Slide 34 text

A CLIENT > Requests data from the server @[email protected]

Slide 35

Slide 35 text

A CLIENT > Requests data from the server > Processes and displays data from the server @[email protected]

Slide 36

Slide 36 text

A CLIENT > Requests data from the server > Processes and displays data from the server > Processes and displays user input @[email protected]

Slide 37

Slide 37 text

A CLIENT > Requests data from the server > Processes and displays data from the server > Processes and displays user input > Sends updated data to the server @[email protected]

Slide 38

Slide 38 text

A CLIENT @[email protected]

Slide 39

Slide 39 text

EXAMPLES OF CLIENTS > Website @[email protected]

Slide 40

Slide 40 text

EXAMPLES OF CLIENTS > Website > iOS App > Android App @[email protected]

Slide 41

Slide 41 text

EXAMPLES OF CLIENTS > Website > iOS App > Android App > Another server not owned by you @[email protected]

Slide 42

Slide 42 text

EXAMPLES OF CLIENTS > Website > iOS App > Android App > Another server not owned by you > An IoT Device @[email protected]

Slide 43

Slide 43 text

Photo via https://flickr.com/photos/ockam/16307930064

Slide 44

Slide 44 text

THE PUBLIC API @[email protected]

Slide 45

Slide 45 text

THE PUBLIC API THE DEFINITION OF HOW THE CLIENT AND SERVER CAN TALK TO EACH OTHER @[email protected]

Slide 46

Slide 46 text

APPLICATION PROGRAMMING INTERFACE @[email protected]

Slide 47

Slide 47 text

INTERFACE @[email protected]

Slide 48

Slide 48 text

Slide 49

Slide 49 text

REST REPRESENTATIONAL STATE TRANSFER @[email protected]

Slide 50

Slide 50 text

api/user/1 { "id": "1", "name": "Bart Simpson" "age": "10" "family_member_ids": [ "2", "3", "4", "5" ] } @[email protected]

Slide 51

Slide 51 text

api/user/1: { "id": "1", "name": "Bart Simpson" "age": "10" "family_members": [ { "id": "2", "name": "Lisa Simpson", "age": 8 }, { "id": 3", "name": "Homer Simpson", "age": 39 }, { "id": "4", "name": "Marge Simpson", "age": 39 }, { "id": "5", "name": "Maggie Simpson", "age": 1 } ] } @[email protected]

Slide 52

Slide 52 text

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Photo via https://flickr.com/photos/johnath/7356295658

Slide 55

Slide 55 text

VAPOR HAS BUILT IN REST SUPPORT @[email protected]

Slide 56

Slide 56 text

Slide 57

Slide 57 text

GRAPHQL A TYPE OF PUBLIC API THAT ALLOWS CLIENTS TO REQUEST SPECIFIC FIELDS FROM THE SERVER @[email protected]

Slide 58

Slide 58 text

Source: https://flickr.com/photos/acaben/2816139/

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

WHAT CAN I ASK FOR? HOW CAN I ASK FOR IT? @[email protected]

Slide 61

Slide 61 text

REST: THERE IS NO STANDARD WAY @[email protected]

Slide 62

Slide 62 text

GOOD: OPENAPI (FKA SWAGGER) @[email protected]

Slide 63

Slide 63 text

GOOD: OPENAPI (FKA SWAGGER) @[email protected]

Slide 64

Slide 64 text

LESS GOOD... @[email protected]

Slide 65

Slide 65 text

"Oh no, we don't have any place where all the HTTP endpoints are written down. Just grep the codebase of the monolith, that should get you what you need." @[email protected]

Slide 66

Slide 66 text

"Oh no, we don't have any place where all the HTTP endpoints are written down. Just grep the codebase of the monolith, that should get you what you need." (An actual thing someone told me to do the first week of a new job)

Slide 67

Slide 67 text

Slide 68

Slide 68 text

THE GRAPHQL SCHEMA @[email protected]

Slide 69

Slide 69 text

THE GRAPHQL SCHEMA A CONTRACT OF WHAT CAN BE REQUESTED, WHAT WILL BE RETURNED, AND HOW @[email protected]

Slide 70

Slide 70 text

IN THE SCHEMA > Scalars @[email protected]

Slide 71

Slide 71 text

IN THE SCHEMA > Scalars > Custom Types @[email protected]

Slide 72

Slide 72 text

IN THE SCHEMA > Scalars > Custom Types > Fields/Properties @[email protected]

Slide 73

Slide 73 text

IN THE SCHEMA > Scalars > Custom Types > Fields/Properties > Relationships (inferred) @[email protected]

Slide 74

Slide 74 text

A NOTE ABOUT GRAPHQL ❓ OPTIONALITY @[email protected]

Slide 75

Slide 75 text

is Optional Swift Type GraphQL Type @[email protected]

Slide 76

Slide 76 text

is Optional Swift Type GraphQL Type No @[email protected]

Slide 77

Slide 77 text

is Optional Swift Type GraphQL Type No String @[email protected]

Slide 78

Slide 78 text

is Optional Swift Type GraphQL Type No String String! @[email protected]

Slide 79

Slide 79 text

Slide 80

Slide 80 text

GRAPHQL TYPES ARE NULLABLE BY DEFAULT @[email protected]

Slide 81

Slide 81 text

is Optional Swift Type GraphQL Type No String String! @[email protected]

Slide 82

Slide 82 text

is Optional Swift Type GraphQL Type No String String! Yes @[email protected]

Slide 83

Slide 83 text

is Optional Swift Type GraphQL Type No String String! Yes String? @[email protected]

Slide 84

Slide 84 text

is Optional Swift Type GraphQL Type No String String! Yes String? String @[email protected]

Slide 85

Slide 85 text

A GRAPHQL OPERATION @[email protected]

Slide 86

Slide 86 text

A GRAPHQL OPERATION A DEFINITION OF A REQUEST TO FETCH, CHANGE, OR LISTEN TO CHANGES FOR YOUR DATA @[email protected]

Slide 87

Slide 87 text

OPERATIONS > Query: I'd like some info, please @[email protected]

Slide 88

Slide 88 text

OPERATIONS > Query: I'd like some info, please > Mutation: I'd like to make a change @[email protected]

Slide 89

Slide 89 text

OPERATIONS > Query: I'd like some info, please > Mutation: I'd like to make a change > Subscription: Keep me up to date on changes @[email protected]

Slide 90

Slide 90 text

OPERATIONS > Query: I'd like some info, please > Mutation: I'd like to make a change > Subscription: Keep me up to date on changes @[email protected]

Slide 91

Slide 91 text

Slide 92

Slide 92 text

HOW DO WE COMBINE VAPOR AND GRAPHQL? @[email protected]

Slide 93

Slide 93 text

Photo: https://flickr.com/photos/daveseven/6138666188

Slide 94

Slide 94 text

`HTTPS://GITHUB.COM/DESIGNATEDNERD/ MOVEITMOVEIT @[email protected]

Slide 95

Slide 95 text

GRAPHQLKIT @[email protected]

Slide 96

Slide 96 text

dependencies: [ .package(url: "https://github.com/alexsteinerde/graphql-kit.git", from: "2.0.0"), ], @[email protected]

Slide 97

Slide 97 text

Slide 98

Slide 98 text

WHAT IS ALL THIS? @[email protected]

Slide 99

Slide 99 text

Source: https://flickr.com/photos/xurble/378943497

Slide 100

Slide 100 text

Source: https://flickr.com/photos/xurble/378943497

Slide 101

Slide 101 text

Source: https://flickr.com/photos/xurble/378943497

Slide 102

Slide 102 text

HIGHEST LEVEL ⬇ LOWEST LEVEL @[email protected]

Slide 103

Slide 103 text

GRAPHQLKIT @[email protected]

Slide 104

Slide 104 text

GRAPHQLKIT EASY GRAPHQL INTEGRATION WITH A VAPOR SERVER @[email protected]

Slide 105

Slide 105 text

GRAPHITI @[email protected]

Slide 106

Slide 106 text

GRAPHITI HELPS YOU BUILD A GRAPHQL SCHEMA IN SWIFT @[email protected]

Slide 107

Slide 107 text

GRAPHQLSWIFT/GRAPHQL @[email protected]

Slide 108

Slide 108 text

GRAPHQLSWIFT/GRAPHQL THE ABSOLUTE BASE HANDLING OF GQL IN SWIFT @[email protected]

Slide 109

Slide 109 text

VAPOR + FLUENT @[email protected]

Slide 110

Slide 110 text

VAPOR + FLUENT (YOU KNOW THESE TWO ALREADY) @[email protected]

Slide 111

Slide 111 text

No content

Slide 112

Slide 112 text

// These all get pulled automatically with GraphQL kit, but you need // to explicitly declare them as dependencies to use them directly. .package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.0.0")), .package(url: "https://github.com/vapor/fluent.git", .upToNextMajor(from: "4.0.0")), .package(url: "https://github.com/vapor/fluent-sqlite-driver.git", .upToNextMajor(from: "4.0.0")), .package(url: "https://github.com/GraphQLSwift/Graphiti", .upToNextMinor(from: "0.26.0")), @[email protected]

Slide 113

Slide 113 text

.target(name: "App", dependencies: [ .product(name: "Fluent", package: "fluent"), .product(name: "FluentSQLiteDriver", package: "fluent-sqlite-driver"), .product(name: "Vapor", package: "vapor"), .product(name: "GraphQLKit", package: "graphql-kit"), .product(name: "GraphiQLVapor", package: "graphiql-vapor"), ]), @[email protected]

Slide 114

Slide 114 text

LET'S BUILD A GRAPHQL API! @[email protected]

Slide 115

Slide 115 text

BACKING OBJECT CREATION @[email protected]

Slide 116

Slide 116 text

BACKING OBJECT CREATION: THE SAME AS FOR REST @[email protected]

Slide 117

Slide 117 text

final class User: Model, Content { static var schema = "users" @ID(key: .id) var id: UUID? @Field(key: "email") var email: String @Field(key: "name") var name: String @Field(key: "hashedPassword") var hashedPassword: String @Children(for: \.$user) var moves: [Move] // ... } @[email protected]

Slide 118

Slide 118 text

final class User: Model, Content { static var schema = "users" @ID(key: .id) var id: UUID? @Field(key: "email") var email: String @Field(key: "name") var name: String @Field(key: "hashedPassword") var hashedPassword: String @Children(for: \.$user) var moves: [Move] // ... } @[email protected]

Slide 119

Slide 119 text

No content

Slide 120

Slide 120 text

final class User: Model, Content { static var schema = "users" @ID(key: .id) var id: UUID? @Field(key: "email") var email: String @Field(key: "name") var name: String @Field(key: "hashedPassword") var hashedPassword: String @Children(for: \.$user) var moves: [Move] // ... } @[email protected]

Slide 121

Slide 121 text

final class User: Model, Content { static var schema = "users" @ID(key: .id) var id: UUID? @Field(key: "email") var email: String @Field(key: "name") var name: String @Field(key: "hashedPassword") var hashedPassword: String @Children(for: \.$user) var moves: [Move] // ... } @[email protected]

Slide 122

Slide 122 text

final class User: Model, Content { static var schema = "users" @ID(key: .id) var id: UUID? @Field(key: "email") var email: String @Field(key: "name") var name: String @Field(key: "hashedPassword") var hashedPassword: String @Children(for: \.$user) var moves: [Move] // ... } @[email protected]

Slide 123

Slide 123 text

final class User: Model, Content { static var schema = "users" @ID(key: .id) var id: UUID? @Field(key: "email") var email: String @Field(key: "name") var name: String @Field(key: "hashedPassword") var hashedPassword: String @Children(for: \.$user) var moves: [Move] // ... } @[email protected]

Slide 124

Slide 124 text

final class User: Model, Content { static var schema = "users" enum DatabaseKeys: String { case email case name case hashedPassword } @ID(key: .id) var id: UUID? @Field(key: "email") var email: String @Field(key: "name") var name: String @Field(key: "hashedPassword") var hashedPassword: String @Children(for: \.$user) var moves: [Move] // ... } @[email protected]

Slide 125

Slide 125 text

final class User: Model, Content { static var schema = "users" enum DatabaseKeys: String { case email case name case hashedPassword } @ID(key: .id) var id: UUID? @Field(key: DatabaseKeys.email.fieldKey) var email: String @Field(key: DatabaseKeys.name.fieldKey) var name: String @Field(key: DatabaseKeys.hashedPassword.fieldKey) var hashedPassword: String @Children(for: \.$user) var moves: [Move] // ... } @[email protected]

Slide 126

Slide 126 text

CREATING A CONFIG @[email protected]

Slide 127

Slide 127 text

// configures your application public func configure(_ app: Application) throws { app.databases.use(.sqlite(.memory), as: .sqlite) // Create the appropriate migrations app.migrations.add(User.Migration()) app.migrations.add(Move.Migration()) try app.autoMigrate().wait() // Register the schema and its resolver. // TODO } @[email protected]

Slide 128

Slide 128 text

// configures your application public func configure(_ app: Application) throws { app.databases.use(.sqlite(.memory), as: .sqlite) // Create the appropriate migrations app.migrations.add(User.Migration()) app.migrations.add(Move.Migration()) try app.autoMigrate().wait() // Register the schema and its resolver. // TODO } @[email protected]

Slide 129

Slide 129 text

// configures your application public func configure(_ app: Application) throws { app.databases.use(.sqlite(.memory), as: .sqlite) // Create the appropriate migrations app.migrations.add(User.Migration()) app.migrations.add(Move.Migration()) try app.autoMigrate().wait() // Register the schema and its resolver. // TODO } @[email protected]

Slide 130

Slide 130 text

RESOLVER @[email protected]

Slide 131

Slide 131 text

RESOLVER FUNCTION TO GET DATA AND GIVE IT TO GQL @[email protected]

Slide 132

Slide 132 text

BARE-BONES RESOLVER class GraphQLResolver { } @[email protected]

Slide 133

Slide 133 text

DECLARING YOUR SCHEMA @[email protected]

Slide 134

Slide 134 text

let movingSchema = try! Schema { Type(User.self) { Field("id", at: \.id) Field("email", at: \.email) Field("name", at: \.name) } } @[email protected]

Slide 135

Slide 135 text

let movingSchema = try! Schema { Type(User.self) { Field("id", at: \.id) Field("email", at: \.email) Field("name", at: \.name) } } @[email protected]

Slide 136

Slide 136 text

let movingSchema = try! Schema { Type(User.self) { Field("id", at: \.id) Field("email", at: \.email) Field("name", at: \.name) } } @[email protected]

Slide 137

Slide 137 text

No content

Slide 138

Slide 138 text

// configure.swift // Register the schema and its resolver. app.register(graphQLSchema: movingSchema, withResolver: GraphQLResolver()) @[email protected]

Slide 139

Slide 139 text

Slide 140

Slide 140 text

"YOU FORGOT TO DECLARE THIS TYPE IN THE SCHEMA, YA DING DONG" @[email protected]

Slide 141

Slide 141 text

let movingSchema = try! Schema { Scalar(UUID.self) Type(User.self) { Field("id", at: \.id) Field("email", at: \.email) Field("name", at: \.name) } } @[email protected]

Slide 142

Slide 142 text

Slide 143

Slide 143 text

let movingSchema = try! Schema { Scalar(UUID.self) Type(User.self) { Field("id", at: \.id) Field("email", at: \.email) Field("name", at: \.name) } } @[email protected]

Slide 144

Slide 144 text

Slide 145

Slide 145 text

Slide 146

Slide 146 text

let movingSchema = try! Schema { Scalar(UUID.self) Type(User.self) { Field("id", at: \.id, as: UUID.self) Field("email", at: \.email) Field("name", at: \.name) } } @[email protected]

Slide 147

Slide 147 text

Slide 148

Slide 148 text

Slide 149

Slide 149 text

Slide 150

Slide 150 text

HANDLING OPERATIONS @[email protected]

Slide 151

Slide 151 text

Mutation { Field("createUser", at: GraphQLResolver.createUser) { Argument("name", at: \.name) Argument("email", at: \.email) Argument("password", at: \.password) } } @[email protected]

Slide 152

Slide 152 text

Mutation { Field("createUser", at: GraphQLResolver.createUser) { Argument("name", at: \.name) Argument("email", at: \.email) Argument("password", at: \.password) } } @[email protected]

Slide 153

Slide 153 text

Mutation { Field("createUser", at: GraphQLResolver.createUser) { Argument("name", at: \.name) Argument("email", at: \.email) Argument("password", at: \.password) } } @[email protected]

Slide 154

Slide 154 text

struct UserCreateArguments: Codable { let name: String let email: String let password: String } extension GraphQLResolver { func createUser(request: Request, arguments: UserCreateArguments) throws -> EventLoopFuture { let user = try User(email: arguments.email, password: arguments.password, name: arguments.name) return user.create(on: request.db).map { user } } } @[email protected]

Slide 155

Slide 155 text

struct UserCreateArguments: Codable { let name: String let email: String let password: String } extension GraphQLResolver { func createUser(request: Request, arguments: UserCreateArguments) throws -> EventLoopFuture { let user = try User(email: arguments.email, password: arguments.password, name: arguments.name) return user.create(on: request.db).map { user } } } @[email protected]

Slide 156

Slide 156 text

struct UserCreateArguments: Codable { let name: String let email: String let password: String } extension GraphQLResolver { func createUser(request: Request, arguments: UserCreateArguments) throws -> EventLoopFuture { let user = try User(email: arguments.email, password: arguments.password, name: arguments.name) return user.create(on: request.db).map { user } } } @[email protected]

Slide 157

Slide 157 text

Mutation { Field("createUser", at: GraphQLResolver.createUser) { Argument("name", at: \.name) Argument("email", at: \.email) Argument("password", at: \.password) } } @[email protected]

Slide 158

Slide 158 text

Mutation { Field("createUser", at: GraphQLResolver.createUser) { Argument("name", at: \.name) Argument("email", at: \.email) Argument("password", at: \.password) } } @[email protected]

Slide 159

Slide 159 text

TRYING IT OUT @[email protected]

Slide 160

Slide 160 text

EASIEST: GRAPHIQL @[email protected]

Slide 161

Slide 161 text

// Something to help visualize and test your schema and operations .package(url: "https://github.com/alexsteinerde/graphiql-vapor.git", .upToNextMajor(from: "2.0.0")), @[email protected]

Slide 162

Slide 162 text

.target(name: "App", dependencies: [ // (existing dependencies) .product(name: "GraphiQLVapor", package: "graphiql-vapor"), ]), @[email protected]

Slide 163

Slide 163 text

import GraphiQLVapor public func configure(_ app: Application) throws { //... (stuff you already saw) // Enable GraphiQL web page for built-in goodness if !app.environment.isRelease { app.enableGraphiQL() } } @[email protected]

Slide 164

Slide 164 text

No content

Slide 165

Slide 165 text

Slide 166

Slide 166 text

No content

Slide 167

Slide 167 text

Slide 168

Slide 168 text

Slide 169

Slide 169 text

APOLLO STUDIO HTTPS://STUDIO.APOLLOGRAPHQL.COM/SANDBOX/EXPLORER @[email protected]

Slide 170

Slide 170 text

Slide 171

Slide 171 text

Slide 172

Slide 172 text

Slide 173

Slide 173 text

No content

Slide 174

Slide 174 text

Slide 175

Slide 175 text

CORS: CROSS-ORIGIN RESOURCE SHARING @[email protected]

Slide 176

Slide 176 text

CORS: CROSS-ORIGIN RESOURCE SHARING (DISABLED BY DEFAULT IN VAPOR) @[email protected]

Slide 177

Slide 177 text

let corsConfiguration = CORSMiddleware.Configuration( allowedOrigin: .custom("https://studio.apollographql.com"), allowedMethods: [.POST], allowedHeaders: [ .accept, .contentType, .accessControlAllowOrigin, .origin ] ) let cors = CORSMiddleware(configuration: corsConfiguration) app.middleware.use(cors) @[email protected]

Slide 178

Slide 178 text

! PITFALLS @[email protected]

Slide 179

Slide 179 text

LOTS OF FIGHTING WITH THE COMPILER @[email protected]

Slide 180

Slide 180 text

No content

Slide 181

Slide 181 text

THERE CAN ONLY BE ONE (RESOLVER CLASS) @[email protected]

Slide 182

Slide 182 text

class MoveResolver { private let userResolver = UserResolver() // MARK: - Pass-Through Methods func createUser(request: Request, arguments: UserCreateArguments) throws -> EventLoopFuture { try userResolver.createUser(request: request, arguments: arguments) } //... } @[email protected]

Slide 183

Slide 183 text

GraphQLResolver+Moves.swift class GraphQLResolver { func createMove(request: Request, arguments: CreateMoveArguments) -> EventLoopFuture { //... } } GraphQLResolver+Users.swift extension GraphQLResolver func createUser(request: Request, arguments: UserCreateArguments) throws -> EventLoopFuture { //... } } @[email protected]

Slide 184

Slide 184 text

DATA LOADING INEFFICIENCIES @[email protected]

Slide 185

Slide 185 text

DATA LOADER @[email protected]

Slide 186

Slide 186 text

404 DATA LOADER NOT FOUND @[email protected]

Slide 187

Slide 187 text

Slide 188

Slide 188 text

THE VERDICT: @[email protected]

Slide 189

Slide 189 text

THE VERDICT: IT DEPENDS @[email protected]

Slide 190

Slide 190 text

No content

Slide 191

Slide 191 text

THE VERDICTS: > ! If you know a lot about both Vapor/Fluent AND GQL @[email protected]

Slide 192

Slide 192 text

THE VERDICTS > ! If you know a lot about both Vapor/Fluent AND GQL > " If you know a lot about Vapor/Fluent but not GQL @[email protected]

Slide 193

Slide 193 text

THE VERDICTS > ! If you know a lot about both Vapor/Fluent AND GQL > " If you know a lot about Vapor/Fluent but not GQL > # If you know a lot about GQL but not Vapor/Fluent @[email protected]

Slide 194

Slide 194 text

THE VERDICTS > ! If you know a lot about both Vapor/Fluent AND GQL > " If you know a lot about Vapor/Fluent but not GQL > # If you know a lot about GQL but not Vapor/Fluent > $ If you don't know a lot about either one @[email protected]

Slide 195

Slide 195 text

No content

Slide 196

Slide 196 text

OBLIGATORY SUMMARY SLIDE @[email protected]

Slide 197

Slide 197 text

OBLIGATORY SUMMARY SLIDE > ! If you know a lot about both Vapor/Fluent AND GQL > " If you know a lot about Vapor/Fluent but not GQL > # If you know a lot about GQL but not Vapor/Fluent > $ If you don't know a lot about either one @[email protected]

Slide 198

Slide 198 text

THANK YOU! @[email protected]

Slide 199

Slide 199 text

LINKS! > Vapor/Fluent Docs: https://docs.vapor.codes/ > GraphQLKit: https://github.com/alexsteinerde/ graphql-kit/ > (slightly outdated) Tutorial on getting started: https://www.kodeco.com/21148796-graphql- tutorial-for-server-side-swift-with-vapor- getting-started @[email protected]