Jon Rumsey

An online markdown blog and knowledge repository.


Project maintained by nojronatron Hosted on GitHub Pages — Theme by mattgraham

Serverless, Amplify and GraphQL

Resources

What is Serverless Architecture? By Hackernoon.com

Amazon AWS Amplify

Data Modeling at Amplify Docs

Serverless Architecture

A buzzword!

It is:

Sample of CSPs and their Serverless offerings:

Down-sides:

Functions As A Service (FaaS):

Serverless Solution Example:

Common Serverless Frameworks and Architectures:

Serverless Examples

Anaibol Awesome-serverless

Build serverless contact form for static websites

Amazon AWS Amplify

Purpose-built tools and features.

FE Web and Mobile full-stack apps on AWS.

Configure web, mobile, backend for your app, visually, with content management.

Tools:

Use Cases:

AWS Amplify Docs

Data Modeling With GraphQL

There are a bunch of code snippets throughout this article.

AWS Amplify automatically creates:

Setup Tables:

  1. type Name @model { content: Type }
  2. amplify push

Queries:

Queries look like a JSON-related plain text file with a heierarchy.

Example query:

query QueryAllThings {
  listThings() {
    things {
      items {
        id
        content
        createdAt
        updatedAt
      }
    }
  }
}
# Lists all 'things' (and their fields/properties?)

Primary Key:

Configure by using @model directive and id will be automatic and primary.

Mark a 2nd field with @primaryKey to specify it as the actual primary key.

Cannot change primary key without deleting/recreating DB table.

Sort Keys:

Use ID! without @primaryKey() directive.

Secondary Index:

Underlying datasource is DynamoDB, a KVP type NoSQL DB.

Model access patterns with secondary indices with @index directive.

Hash Key: Strict equality tester.

Sort Key: Comparisons including GT, LT, non-strict-equals, starts/ends with, and between operations.

sortKeyFields: ["fieldName"], is used within the @index directive.

Relationships Between Models:

Uni-directional 1:1 releationship between 2 models: @hasOne

One-direction 1:N relationship between 2 models: @hasMany

Has One or Has Many bi-directionsl relationship: @belongsTo

Join-Tables between 2 models for N:N relationships: @manyToMany

Note: Avoid circular relationships between uni-directional relationship tables, or uni- and many- relationship tables.

Bi-directional HasOne and HasMany relationships can be configured.

Default Field Values:

Use @default directive for scalar type fields e.g. int, string, etc.

An example from [Amplify Docs]:

type Todo @model {
  content: String @default(value: "My new Todo")
}

Rename and Disable:

Can be done to GraphQL queries, mutations, and supscriptions with name overrides, and nulling a value.

Other Comments:

How It Works

See the bottom section of the site labeled How It Works for details on:

Return to Root README