Skip to content

Instantly share code, notes, and snippets.

View rubycut's full-sized avatar

Rubycut rubycut

View GitHub Profile
@rubycut
rubycut / resolver.js
Last active October 8, 2017 16:54
graphql article
const resolvers = {
Query: {
customer(root, args, context,info) {
var c = Customer.findForUser(context,args.id).populate('contacts')
}
}
}
import {Cluster} from './cluster.js'
const graphqlFields = require('graphql-fields');
import * as _ from 'lodash'
const resolvers = {
Query: {
customer(root, args, context,info) {
var requested_fields = Object.keys(graphqlFields(info))
var c = Cluster.findForUser(context,args.id)
Promise.all(my_array.map(async (myObject) => {
await myObject.httpPost()
}
import pLimit from "p-limit"
import PromiseBar from "promise.bar"
PromiseBar.enable()
// set concurrency
const limit = pLimit(5)
// create array which we will use to throttle requests
const requests = []
import { Document, Schema, Model, model, Types } from "mongoose"
// We are definining typescript basic typescript interface first, properties only
export interface IHouse {
id?: any
name: string
rooms: Types.DocumentArray<IRoomDocument>
owners: Types.DocumentArray<IOwnerDocument>
}