Skip to content

Instantly share code, notes, and snippets.

View JeffML's full-sized avatar
🏠
Barely working

Jeff Lowery JeffML

🏠
Barely working
View GitHub Profile
const stuff = {
isWombat: true,
sugar: ["in the morning", "in the evening", "at suppertime"]
}
instance.newStuff = stuff;
instance.getStuff();
instance.newStuff.sugar = ["You are my candy, girl", "and you keep me wanting you"];
import express from 'express';
import { ApolloServer } from 'apollo-server-express';
import http from 'http';
import { typeDefs } from './schema';
import resolvers from './resolvers';
const PORT = 3031;
const app = express();
import { makeExecutableSchema } from 'graphql-tools';
import resolvers from './resolvers';
const typeDefs = [
`
type Query {
go: String!
}
type Subscription {
import { PubSub } from 'apollo-server-express';
const pubsub = new PubSub();
const TOPIC = 'infoTopic';
const infos = ['info1', 'info2', 'info3', 'done']
const publish = () => {
setTimeout( () =>
infos.forEach(info => pubsub.publish(TOPIC, {info})), 1000)
@JeffML
JeffML / fetch.js
Last active December 29, 2018 23:55
/* eslint-env mocha */
/* eslint-disable import/no-extraneous-dependencies */
// see https://www.apollographql.com/docs/link/index.html#standalone
import fetch from 'node-fetch';
import { execute, makePromise } from 'apollo-link';
import { WebSocketLink } from 'apollo-link-ws';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import ws from 'ws';
import { HttpLink } from 'apollo-link-http';
/* eslint-env mocha */
import chai from 'chai';
import fetch, { subscribe } from './fetch';
chai.should();
describe('subscribe, then go', function () {
this.timeout(5000);
const handlers = {
const { workerData, parentPort, isMainThread } = require("worker_threads");
// You can do any heavy stuff here, in a synchronous way
// without blocking the "main thread"
parentPort.on("message", message => {
if (message === "exit") {
parentPort.postMessage("sold!");
parentPort.close();
} else {
parentPort.postMessage({ going: message });
const { Worker, isMainThread } = require("worker_threads");
function runService(workerData) {
const worker = new Worker("./service.js", { workerData });
worker.postMessage("once");
worker.on("message", incoming => console.log({ incoming }));
worker.on("error", code => new Error(`Worker error with exit code ${code}`));
worker.on("exit", code =>
console.log(`Worker stopped with exit code ${code}`)
);
import React, { Fragment } from 'react';
import { Query } from 'react-apollo';
import gql from 'graphql-tag';
const qLaunches = gql`query ls {
launches {
launches {
id
site
mission {
// Editor.js
const LOGIN = gql`
mutation login {
login(email:"${faker.internet.email}")
}
`
const Submit = (props) => {
return <Mutation mutation={LOGIN} update={(cache, { data }) => sessionStorage.setItem('auth', data.login)}>