Carlos Rufo
Polyglot Engineer โข @GraphQLHongKong organizer โข api.spacex.land author โข he/him
๐คฉ Desktop ~ 100% ย
๐ง Mobile ~ 60%
๐ฑ Watch ~ 20%
๐ /desktop/launches
๐คจ /mobile/launches
๐ค /watch/launches
๐คฉ /launches - 1 HTTP/DB
๐ง /rocket/:id - 'N' HTTP/DB
๐ญ Client parse functions
๐ /graphql - 1 HTTP/'N' DB
๐ No client parse functions
Schema First
๐ Fully client-focused (SDL)
๐ Code reuse, Type safety
๐ Apollo Server
Resolver First
๐ Lowest abstraction level
๐ Verbose, Less client focus
๐ graphql.js
Code/Model First
๐ Code reuse, Type safety
๐ Most "distance" between code-schema
๐ GraphQL Nexus
type Query {
launches: [Launch]
launch(id: ID!): Launch
}
type Launch {
id: ID!
name: String
details: String
image: String
rocket: Rocket
ship: Ship
}
type Rocket {
id: ID!
name: String
}
type Ship {
id: ID!
name: String
port: String
image: String
}
Query: {
launches: async (obj, args, context) => {
const data = await context.db
.collection('launch')
.toArray();
return data;
},
launch: async (obj, { id }, context) => {
const [data] = await context.db
.collection('launch')
.find({ id })
.toArray();
return data;
},
}
Type Definitions
Resolvers
tsc --version # 3.3
TypeScript NYC Meetup
By Carlos Rufo
Polyglot Engineer โข @GraphQLHongKong organizer โข api.spacex.land author โข he/him