Reductive Badassery

Mitch Masia

A serverless GraphQL API gateway PoC

Hexient Labs

Who?

2018 == Buzzwords

Today's Goal

Context

We're engineers at a large retail chain

Our online ordering portal is powered by a service-oriented architecture

User Service

Cart Service

Checkout Service

Context

Right now, the clients hit multiple endpoints to request/manipulate data

We're looking to simplify front-end dev processes by creating a single access-point

Context

Context

Context

For simplicity, we will not focus on Authentication or Authorization

All Queries and mutations will be in the context of the currently logged-in user

Our Stack

User Service

type User {
  email: String!
  firstName: String
  id: ID!
  lastName: String
}

input UserInput {
  email: String!
  firstName: String
  lastName: String
}

type Query {
  currentUser: User!
}

type Mutation {
  register(user: UserInput!): User!
}
                                                                

Cart Service

type CartItem {
  productId: ID!
  quantity: Int!
} 

type Cart {
  items: [CartItem!]!
}

input CartItemInput {
  productId: ID!
  quantity: Int!
}

type Query {
  cartForCurrentUser: Cart!
}

type Mutation {
  addItemToCart(cartItem: CartItemInput!): Cart!
}
                                                                

Checkout Service

enum OrderStatus {
  CANCELLED
  COMPLETE
  NEW
}

type Order {
  id: ID!
  status:  OrderStatus!
}

input CreateOrderInput {
  stripeCardToken: String!
}
  

type Query {
  ordersForCurrentCustomer: [Orders!]!
}

type Mutation {
  createOrder(inputs: CreateOrderInput!): Order!
}
                                                                
Made with Slides.com