Skip to content

Apollograph federation - Subgraph POC with AWS lambda local, Postgres and Sequelize using SAM

Notifications You must be signed in to change notification settings

pybala/apollo_subgraph_lambda_poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

AWS SAM Lambda - local

sam build
sam local start-api

Make sure you have the scripts in package.json like below ("prepare" is important)

"scripts": {
    "build": "tsc",
    "prepare": "npm run build",
},

We dont have to run npm build, sam build will take care of transpiling ts and put it under dist folder

Example GraphQL query

query GetProductInfo ($item_id: Int!, $category_id: Int!) {
    getProductInfo (item_id: $item_id, category_id: $category_id) {
        item_id
        category_id
        unit_in_stock
        last_updated_at
    }
}
curl --location 'http://127.0.0.1:3000/graphql' \
--header 'X-Api-Key: test-bT3LQkqKUzsGrxkhL0dZwYqptIuViwjVh72XS2Z9' \
--header 'Content-Type: application/json' \
--data '{"query":"query GetProductInfo ($item_id: Int!, $category_id: Int!) {\n  getProductInfo (item_id: $item_id, category_id: $category_id) {\n    item_id\n    category_id\n    unit_in_stock\n  }\n}","variables":{"item_id":12345,"category_id":12}}'
import requests
import json

url = "http://127.0.0.1:3000/graphql"

payload = "{\"query\":\"query GetProductInfo ($item_id: Int!, $category_id: Int!) {\\n  getProductInfo (item_id: $item_id, category_id: $category_id) {\\n    item_id\\n    category_id\\n    unit_in_stock\\n  }\\n}\",\"variables\":{\"item_id\":33535,\"category_id\":15}}"
headers = {
  'X-Api-Key': 'test-bT3LQkqKUzsGrxkhL0dZwYqptIuViwjVh72XS2Z9',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

About

Apollograph federation - Subgraph POC with AWS lambda local, Postgres and Sequelize using SAM

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published