View on GitHub

reads

https://yazansneneh.github.io/reads/

Read: 33 - GraphQL @connection

review: Intro to Serverless

Pros & Cons

Functions as a Service (FaaS)

Traditional vs. Serverless Architecture

Traditional vs. Serverless Architecture

review: AWS Amplify Kool-Aid

GraphQL @connection section

Add relationships between types

one to one

project have one team

type Project @model {
  id: ID!
  name: String
  team: Team @connection
}

type Team @model {
  id: ID!
  name: String!
}

one to many

post has many comments

type Post @model {
  id: ID!
  title: String!
  comments: [Comment] @connection(keyName: "byPost", fields: ["id"])
}

type Comment @model
  @key(name: "byPost", fields: ["postID", "content"]) {
  id: ID!
  postID: ID!
  content: String!
}

many to many

Create a join model and disable queries as you don’t need them

and can query through Post.editors and User.posts

type PostEditor @model(queries: null) @key(name: “byPost”, fields: [“postID”, “editorID”]) @key(name: “byEditor”, fields: [“editorID”, “postID”]) { id: ID! postID: ID! editorID: ID! post: Post! @connection(fields: [“postID”]) editor: User! @connection(fields: [“editorID”]) }

type User @model { id: ID! username: String! posts: [PostEditor] @connection(keyName: “byEditor”, fields: [“id”]) } ```