Skip to content

Instantly share code, notes, and snippets.

@idibidiart
idibidiart / GraphQL-Architecture.md
Last active September 16, 2023 18:36
Building an Agile, Maintainable Architecture with GraphQL

Building a Maintainable, Agile Architecture for Realtime, Transactional Apps

A maintainable application architecture requires that the UI only contain the rendering logic and execute queries and mutations against the underlying data model on the server. A maintainable architecture must not contain any logic for composing "app state" on the client as that would necessarily embed business logic in the client. App state should be persisted to the database and the client projection of it should be composed in the mid tier, and refreshed as mutations occur on the server (and after network interruption) for a highly interactive, realtime UX.

With GraphQL we are able to define an easy-to-change application-level data schema on the server that captures the types and relationships in our data, and wiring it to data sources via resolvers that leverage our db's own query language (or data-oriented, uniform service APIs) to resolve client-specified "queries" and "mutations" against the schema.

We use GraphQL to dyn

@fdecampredon
fdecampredon / Container.js
Last active August 27, 2017 17:04
redux-relay
import React from 'react';
import { container } from 'redux-relay';
@container({
variablesFromState: (state) => ({myVariable: state.myState})
fragments: {
Relay.QL`
viewer {
@alexhawkins
alexhawkins / lastSurvivor.js
Last active August 29, 2015 14:14
Last Survivor Coding Question
'use strict';
/** APPLICANT INFO ***********************************************************
------------------------------------------------------------------------------
* Name: Alex Hawkins
* Email: alexhawkins.me@gmail.com
* GitHub: github.com/alexhawkins
* LinkedIn: linkedin.com/in/alexhawkinsme/
****************************************************************************/
@alexhawkins
alexhawkins / HashTable.js
Last active August 7, 2021 23:33
Correct Implementation of a Hash Table in JavaScript
var HashTable = function() {
this._storage = [];
this._count = 0;
this._limit = 8;
}
HashTable.prototype.insert = function(key, value) {
//create an index for our storage location by passing it through our hashing function
var index = this.hashFunc(key, this._limit);
@alexhawkins
alexhawkins / JSON.stringify.js
Last active August 29, 2015 14:06
Hardly Readable JSON.stringify Implementation
var stringifyJSON = function(obj) {
var objElements = [];
//check for literals
if (!(obj instanceof Object))
return typeof obj === 'string' ? '"' + obj + '"' : '' + obj;
//check for arrays
else if (Array.isArray(obj)) {
return '[' + obj.map(function(el) { return stringifyJSON(el); }) + ']';
//check for object if not array
} else if (obj instanceof Object) {
@wulymammoth
wulymammoth / functionalJS.js
Created August 11, 2014 22:27
From Imperative to Functional JS
/**
* Write a simple join function in the various styles:
* 1. Imperative
* 2. Object-oriented
* 3. Functional language
*/
// Imperative
function simpleJoin( stringArray ) {
var accumulator = '';