Skip to content

Latest commit

 

History

History
191 lines (174 loc) · 4.61 KB

README.md

File metadata and controls

191 lines (174 loc) · 4.61 KB

GRAPHQL FEDERATIONS

Setup

  1. yarn install
  2. yarn dynamo:install // installs a local dynamo for use with the offline plugin
  3. yarn start // starts up the offline server with all 4 lambdas
  4. navigate to http://localhost:4001/dev/gw to start playing with the api

Relationships

Model

classDiagram
direction LR
Car "1" --> "*" Charger 
Driver "*" -- "*" Car 
Charger "*" <-- "1" Driver 
Loading

One to Many

  1. Charger 1 - * Car
classDiagram
direction LR
Car "1" --> "*" Charger
Loading
sequenceDiagram
Car.Req-->>+Car: Car Req
Car->>+CarTable: Get Car
CarTable-->>-Car: Car 
Car->>+Charger.Car: Chargers by Car Id
Charger.Car->>+ChargerTable: Chargers by Car Id 
ChargerTable-->>-Charger.Car: chargers
Charger.Car-->>-Car: Chargers
Car-->>-Car.Req: Car With Chargers 
Loading

Logging

- ------------------------- CAR REQ {
  "query": "query ONE_TO_MANY_CAR_CHARGERS__cars__0($ids:[ID]){cars(ids:$ids){__typename id name registrationNumber}}",
  "variables": {
  "ids": [
  "1"
  ]
  },
  "operationName": "ONE_TO_MANY_CAR_CHARGERS__cars__0"
  }

  1. ------------------------- CAR - CARS
- ------------------------- CHARGER REQ {
  "query": "query ONE_TO_MANY_CAR_CHARGERS__chargers__1($representations:[_Any!]!){_entities(representations:$representations){...on Car{chargers{id productName}}}}",
  "variables": {
  "representations": [
  {
  "__typename": "Car",
  "id": "1"
  }
  ]
  },
  "operationName": "ONE_TO_MANY_CAR_CHARGERS__chargers__1
  }

    • 2 ----------------------- CHARGER -> CAR - CHARGERS 1

Many to One

  1. Car * - 1 Charger
classDiagram
direction LR
Charger "*" --> "1" Car
Loading
sequenceDiagram
Charger.Req->>+Charger: Charger Request
Charger->>+ChargerTable: Get Charger 
ChargerTable-->>-Charger: Charger with Car id
Charger-->>Charger: Car Ref ( type/id ) 
Charger->>+Car._resolveRefernce: Car Req
Car._resolveRefernce-->>-Charger: Resolved Car
Charger-->>-Charger.Req:  Chargers with Car 
Loading

Logging

  1. ------------------------- CHARGER REQ {
     "query": "query MANY_TO_ONE_CAR_CHARGER__chargers__0($ids:[ID]){chargers(ids:$ids){id productName car{__typename id}}}",
     "variables": {
     "ids": [
     "1"
     ]
     },
     "operationName": "MANY_TO_ONE_CAR_CHARGER__chargers__0"
     }
    
    
  2. ----------------------- CHARGER - CHARGERS
  3. ------------------------- CHARGER - CAR 1
  ------------------------- CAR REQ {
    "query": "query MANY_TO_ONE_CAR_CHARGER__cars__1($representations:[_Any!]!){_entities(representations:$representations){...on Car{registrationNumber}}}",
    "variables": {
    "representations": [
    {
    "__typename": "Car",
    "id": "1"
    }
    ]
    },
    "operationName": "MANY_TO_ONE_CAR_CHARGER__cars__1"
  } 
  1. ####### Resolve Car { __typename: 'Car', id: '1' }

Many to Many

  1. Car * - * Driver
classDiagram
direction LR
Car "*" --> "*" Driver
Loading
sequenceDiagram
Car.Req->>+Car: Car Request
Car->>+CarTable: Get Car
CarTable-->>-Car: Car with driver ids
Car-->>Car: Drivers Resolver return Refs ( type/id ) 
Car->>+Driver._resolveRefernce: Driver Req
Driver._resolveRefernce-->>-Car: Resolved Drivers 
Car-->>-Car.Req:  Cars with Drivers
Loading

Logging

   - ------------------------- CAR REQ {
  "query": "query MANY_TO_MANY_CAR_DRIVER__cars__0($ids:[ID]){cars(ids:$ids){id name registrationNumber drivers{__typename id}}}",
  "variables": {
  "ids": [
  "1"
  ]
  },
  "operationName": "MANY_TO_MANY_CAR_DRIVER__cars__0"
  }
  1. ------------------------- CAR - CARS
  2. ------------------------- CAR - DRIVERS
  - ------------------------- DRIVER REQ {
  "query": "query MANY_TO_MANY_CAR_DRIVER__drivers__1($representations:[_Any!]!){_entities(representations:$representations){...on Driver{email}}}",
  "variables": {
    "representations": [
      {
        "__typename": "Driver",
        "id": "1"
      },
      {
        "__typename": "Driver",
        "id": "2"
      }
    ]
  },
  "operationName": "MANY_TO_MANY_CAR_DRIVER__drivers__1"
}

  1. ####### Resolve Drivers { __typename: 'Driver', id: '1' }
  2. ####### Resolve Drivers { __typename: 'Driver', id: '2' }
  3. !!!!!!!!!!! load drivers [ '1', '2' ] -- Dataloader