Skip to content

Instantly share code, notes, and snippets.

View coco98's full-sized avatar

Tanmai Gopal coco98

View GitHub Profile
@coco98
coco98 / elgordino-hasura.tf
Created December 19, 2018 08:31
Terraform spec for Hasura on Fargate and RDS
provider "aws" {
region = "${var.region}"
}
### VPC
# Fetch AZs in the current region
data "aws_availability_zones" "available" {}
resource "aws_vpc" "datastore" {
cidr_block = "172.17.0.0/16"
query {
users {
firstName
}
}
-- AST1
data ColExpression = ColE ColName [OperationExpression]
data BoolExpression = BECol ColExpression
data BoolExpression
= BEAnd [BoolExpression]
| BEOr [BoolExpression]
| BENot BoolExpression
| BECol ColExpression
// Boolean expression for a column
"column": {
"_eq": "value",
"_gt": "value"
}
// AND expression
"and": {
"column1": {...},
#Query running against data the DB
query {
albums {
id
title
}
}
#Query running against your own code that may or may not talk to the database
#These APIs are hosted at: https://graphql-pokemon.now.sh
query fetchOrders {
order (limit: 10, order_by:created_at_desc) {
id
user_name
items {
detail {
id
name
}
}
@coco98
coco98 / serverless-before-after.md
Last active September 5, 2018 09:43
Before/After serverless
Before After
App makes an API request and waits. App makes a GraphQL mutation and then runs a GraphQL subscription to get updates as they happen
Backend API makes multiple API calls, with complex retry and error handling logic Business logic in serverless functions get triggered automatically after the mutation
App receives API response App gets success/error updates as they happen
@coco98
coco98 / hasura-auth-pre-signup-hook.md
Last active June 6, 2018 01:17
Adding a preSignup hook

Requirements

  • You have an existing Hasura project, cluster
  • You have a microservice running where you can add a webhook
  • You have kubectl installed. Check by running: kubectl get pods -n hasura which should list all the hasura microservices

Step 1: Update the platform to v0.15.34+

Check your platform version:

#An array of artists are returned by a GET query to /v1/artists
# artists = [
# {
# "name": "...",
# "genre": "...",
# "albums_recorded": <int>,
# "username": "..."
# }
# ]
#
@coco98
coco98 / simple-query.json
Created April 23, 2018 15:07
Simple query with a JSON DSL
{
"query": "read",
"node": "author",
"columns": [
"id",
"name",
{
"node": "articles",
"columns": ["id", "title"]
}