Skip to content

Instantly share code, notes, and snippets.

View coco98's full-sized avatar

Tanmai Gopal coco98

View GitHub Profile
@coco98
coco98 / server2.js
Created May 28, 2017 06:52
A simple server.js with one endpoint
var express = require('express');
var app = express();
//your routes here
app.get('/respond', function (req, res) {
res.send("Hello World!");
});
app.listen(8080, function () {
console.log('Example app listening on port 8080!');
@coco98
coco98 / server.js
Last active May 28, 2017 07:15
Nodejs service on Hasura making an API request to another API on Hasura
const fetch = require('isomorphic-fetch');
const express = require('express');
const app = express();
//your routes here
app.get('/hello', function (req, res) {
const url = 'http://api2.default/respond';
const options = {
method: 'GET'
@coco98
coco98 / simple-query.graphql
Created April 23, 2018 13:51
A simple "read" query in GraphQL
# Fetch authors and their articles
# and relevant fields within those objects only
query {
author {
id
name
articles {
id
title
}
@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"]
}
#An array of artists are returned by a GET query to /v1/artists
# artists = [
# {
# "name": "...",
# "genre": "...",
# "albums_recorded": <int>,
# "username": "..."
# }
# ]
#
@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:

@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
query fetchOrders {
order (limit: 10, order_by:created_at_desc) {
id
user_name
items {
detail {
id
name
}
}
#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
// Boolean expression for a column
"column": {
"_eq": "value",
"_gt": "value"
}
// AND expression
"and": {
"column1": {...},