Serverless GraphQL with AzureFunctions

@michael_staib

What is Serverless?

  • Serverless still uses servers!

  • Build and run applications without
    thinking about servers.

What is Serverless?

  • No server is provisioned or managed

  • Scales with usage

  • High availability

  • Never pay for idle

Function as form of abstraction

Companies using Serverless

Frameworks

  • Serverless (OSS Framework for AWS)

  • AWS Lambda

  • Azure Functions

  • Google Cloud Functions

Consumption plan

Scale automatically and only pay for compute resources when your functions are running. On the Consumption plan, instances of the Functions host are dynamically added and removed based on the number of incoming events.

Premium plan

While automatically scaling based on demand, use pre-warmed workers to run applications with no delay after being idle, run on more powerful instances, and connect to VNETs.

Azure App Service plan

Run Functions within an App Service plan at regular App Service plan rates. Good fit for long running operations, as well as when more predictive scaling and costs are required.

Functions on Kubernetes

Now in Preview, Functions can run on pre-provisioned Kubernetes clusters in Azure Kubernetes Service or on Arc-enabled clusters on-premises and in other clouds. This capability is currently free* during Preview.

Hosting Models

  • Class library

  • Integrated into function host

  • DryIoc DI

  • .NET Runtime of host process

  • HttpRequest

  • Standard startup times

  • Cancellations allowed

In-process

Out-of-process

  • Fewer conflicts

  • Full control of the process

  • Standard DI

  • .NET Runtime Flexibility

  • HttpRequestData

  • Longer startup times

  • No cancellations

{
  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
}

GraphQL gives clients the power to ask for exactly what they need and nothing more.

Demo

GraphQL

Business Layer

Data Layer

Typical Layers

HTTP

Parse

Validate

Compile

Plan

Execute

GraphQL Request Pipeline

Demo

GraphQL

GraphQL
Services

GraphQL
Services

Rest
Services

Client

Serverless GraphQL Gateway

GraphQL Shop API

Accounts

Product

Reviews

Client

Serverless GraphQL Gateway

Inventor

Demo

GraphQL Subscriptions

GraphQL Subscriptions

Azure Web PubSub

GraphQL Subscriptions

Trigger

Messages

Trigger

Trigger

https://bit.ly/graphql-github

If you like what we do give us a star on GitHub

https://chillicream.com

@michael_staib

Serverless GraphQL with AzureFunctions

By Michael Ingmar Staib

Serverless GraphQL with AzureFunctions

  • 643