Skip to content

Instantly share code, notes, and snippets.

View ragmha's full-sized avatar

Räghib Hasan ragmha

View GitHub Profile
@ragmha
ragmha / Event-stream based GraphQL subscriptions.md
Created May 15, 2019 18:52 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

https://github.com/kentcdodds/react-testing-library/blob/master/examples/__tests__/react-hooks.js
const variables = {
keywords: 'Hello',
limit: 1,
page: 5
}
const qs = Object.keys(variables).reduce(
(acc, key) => {
@ragmha
ragmha / App.js
Created January 6, 2019 11:02 — forked from shelldandy/App.js
nprogress with react-router in create-react-app
import React from 'react'
import { BrowserRouter as Router, Switch } from 'react-router-dom'
import routes from './routes'
import FancyRoute from './components/tools/FancyRoute'
const App = props =>
<Router>
<Switch>
{routes.map((route, i) =>
<FancyRoute key={i} {...route} />
@ragmha
ragmha / utils.js
Created December 23, 2018 12:46
WIP: utility funcs
const getItems = (count) =>
Array.from({ length: count }, (v, k) => k)
.map(k => ({ id: `items-${k}`, content: `item ${k}`}));
console.log(getItems(10))
@ragmha
ragmha / host-react-app-on-apache-server.md
Created December 18, 2018 17:24 — forked from ywwwtseng/host-react-app-on-apache-server.md
Host react application on Apache server

Host react application on Apache server

Step 1 : Create your app

$ npm install -g create-react-app 
$ create-react-app my-app

Step 2 : Build it for production

// Function
function myFunction() {
console.log("Function::", this);
}
myFunction(); // => Window is invoking the function
// Lamda
const myanotherFunc = () => console.log("Lamda::", this);
function reverse(str: string): string;
function reverse<T>(arr: T[]): T[];
function reverse<T>(stringOrArray: string | T[]): string | T[] {
if (typeof stringOrArray === "string") {
return stringOrArray
.split("")
.reverse()
.join("");
}
return stringOrArray.slice().reverse();
class Pizza {
constructor(private name: string, private price: number) {}
}
class List<T> {
private list: T[] = [];
addItem(item: T): void {
this.list.push(item);
}