Skip to content

Instantly share code, notes, and snippets.

View coco98's full-sized avatar

Tanmai Gopal coco98

View GitHub Profile
// Boolean expression for a column
"column": {
"_eq": "value",
"_gt": "value"
}
// AND expression
"and": {
"column1": {...},
-- AST1
data ColExpression = ColE ColName [OperationExpression]
data BoolExpression = BECol ColExpression
data BoolExpression
= BEAnd [BoolExpression]
| BEOr [BoolExpression]
| BENot BoolExpression
| BECol ColExpression
query {
users {
firstName
}
}
@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"
mutation($message: messages_insert_input!) {
insert_messages(objects:[$message]) {
returning {
id
sender_id
message
}
}
}
mutation($message: messages_insert_input!) {
insert_messages(objects:[$message]) {
returning {
id
sender_id
message
}
}
}
{
"user": [
{
"id": 456,
"name": "Sita K",
"address": {
"country": "India"
}
},
{
@coco98
coco98 / chinook_hasura_postgres_db.sql
Created January 15, 2019 14:03
Chinook dataset to be imported into postgres - ideal for hasura demo
This file has been truncated, but you can view the full file.
-- -- /*******************************************************************************
-- -- Chinook Database - Version 1.4
-- -- Script: Chinook_PostgreSql.sql
-- -- Description: Creates and populates the Chinook database.
-- -- DB Server: PostgreSql
-- -- Author: Luis Rocha
-- -- License: http://www.codeplex.com/ChinookDatabase/license
-- -- Modified By: John Atten
@coco98
coco98 / update-relationships.graphql
Last active March 13, 2019 06:34
single mutation to update relationships
#Without query variables
mutation updateChildren {
delete_children(where: {parent_id: {_eq: 1}}) {
affected_rows
}
insert_children(objects: [{name: "child1", parent_id: 1}, {name: "child2", parent_id: 1}]) {
affected_rows
}
@coco98
coco98 / track_all_tables.py
Last active September 16, 2021 19:24
Track tables in python (Hasura)
import requests
#Fetch existing tables
tables = requests.post('http://localhost:8080/v1/query', json={
"type":"select",
"args":{
"table": {"schema": "information_schema", "name": "tables"},
"columns": ["table_name"],
"where": {"table_schema": {"$eq": "public"}}
}