Skip to content

Instantly share code, notes, and snippets.

View marcolz's full-sized avatar

Marco Lazzeri marcolz

  • California
View GitHub Profile
@marcolz
marcolz / mockserver-express-graphql.js
Last active June 11, 2019 15:21
Mocking GraphQL with express-graphql
const express = require('express')
const graphqlHTTP = require('express-graphql')
const { buildSchema } = require('graphql')
const { addMockFunctionsToSchema } = require('graphql-tools')
const app = express()
const schema = buildSchema(`
...your schema here...
@marcolz
marcolz / try-like-rails.js
Last active July 19, 2016 00:30
My ES6 implementation of Rails' style #try()
// Traverse an object and attempt to extract the value(s) of one
// or more properties, without worrying about non-Object values.
const maybe = (obj, traverse, fields) => {
if (!(fields instanceof Array)) {
fields = [fields]
}
let result