GraphQL Schema Stitching

with .NET Core

Michael Staib

{
  me {
    name
  }
}
{
  "me": {
    "name": "Michael Staib"
  }
}
{
  me {
    name
  }
}
{
  me {
    name
    image {
      width
      height
      url
    }
  }
}
{
  "me": {
    "name": "Michael Staib",
    "image": {
      "width": 200,
      "height": 300,
      "url": "http://some/images/123.png"          
    }
  }
}
{
  me {
    name
    image {
      width
      height
      url
    }
  }
}
{
  me {
    name
    lastSeen
    friends {
      name
      lastSeen
    }
  }
}
{
  "me": {
    "name": "Michael Staib",
    "lastSeen": "2018-05-19T18:45",
    "friends": [
      {
        "name": "Rafael Staib",
        "lastSeen": "2018-05-24T12:37"
      },
      {
        "name": "Pascal Senn",
        "lastSeen": "2018-06-07T17:13"
      }
    ]
  }
}
{
  me {
    name
    lastSeen
    friends {
      name
      lastSeen
    }
  }
}
{
  "me": {
    "name": "Michael Staib",
    "lastSeen": "2018-05-19T18:45",
    "friends": [
      {
        "name": "Rafael Staib",
        "lastSeen": "2018-05-24T12:37"
      },
      {
        "name": "Pascal Senn",
        "lastSeen": "2018-06-07T17:13"
      }
    ]
  }
}
{
  me {
    ... PersonInfo
    friends {
      ... PersonInfo
    }
  }
}
fragment PersonInfo on Person {
  name
  lastSeen
}
  • One Endpoint
  • One Request
  • No over- or under-fetching
  • Type System
  • Predictable

GraphQL

Business Layer

Storage Layer

type Review {
  body: String
  author: [User]
  product: Product
}
type Product {
  name: String
  price: String
  inStock: Boolean
  shippingEstimate: Int
  reviews: [Review]
}
type User {
  name: String
  reviews: [Review]
}
{
  me {
    name
    reviews {
      body
      product {
        name
      }
    }
  }
}
{
  topProducts(first: 5) {
    name
    shipingEstimate
    inStock
    reviews {
      body
      author {
      	name
      }
    }
  }
}

GraphQL

Account
Service

Products
Service

Client

Review
Service

Inventory
Service

type Review {
  body: String
}
type Product {
  name: String
  price: String
}
type User {
  name: String
}
extend type Product {
  inStock: Boolean
  shippingEstimate: Int
}
extend type Product {
  reviews: [Review]
}
extend type User {
  reviews: [Review]
}

Account

Product

Inventory

Review

extend type Review {
  author: [User]
}
extend type Review {
  product: Product
}

GraphQL

GraphQL

Client

GraphQL

GraphQL

GraphQL

GraphQL

Client

GraphQL

GraphQL

Approaches to Graph Distribution

  • Schema Stitching

  • Schema Federation


Demo
 

Conclusion

  • Iterate faster.

  • Be more flexible.

  • Deploy when you want.

  • Divide your graph into logical units.

https://chillicream.com

https://github.com/chillicream/hotchocolate

NDC London 2021 - Schema Stitching

By Michael Ingmar Staib

NDC London 2021 - Schema Stitching

  • 617