Skip to content

Instantly share code, notes, and snippets.

View warrenday's full-sized avatar

Warren Day warrenday

View GitHub Profile
@warrenday
warrenday / graphcool-autodeploy.js
Created June 22, 2018 10:36
Watch for file changes of a local graphcool service and deploy on change.
const { spawn } = require('child_process');
const watch = require('node-watch');
let commandComplete = true;
watch([
'./src',
'graphcool.yml',
'types.graphql'
], { recursive: true }, function(evt, name) {
if (!commandComplete) {
- name: Run API in background
working-directory: packages/api
run: |
yarn install
yarn mock &
env:
SOME_ENV: 1234
name: Test App
on: [push]
jobs:
build:
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
import { runTestCases } from './test-runner';
const testCases = [
{
id: 'getBooking',
query: `
query ($id: Int!) {
getBooking (id: $id) {
id
cartReference
import { createTestClient } from 'apollo-server-testing';
const { query } = createTestClient();
const res = await query({
query: `
query listBookings {
id
}
`,
import { createTestClient } from 'apollo-server-testing';
import { createServer } from './createServer';
export const runTestCases = (
groupName,
testCases,
) => {
const { query } = createTestClient(createServer());
describe(`${groupName} resolvers`, () => {
exports[`Bookings Integration Tests getBooking`] = `
Object {
"data": Object {
"getBooking": Object {
"id": 1,
"cartReference": "123-123-456",
"paymentAmount": 2000,
"cancelled": false,
"receiptNumber": "456464565",
},
import { ApolloServer } from 'apollo-server';
import { schema } from './schema';
export const createServer = () => {
return new ApolloServer({
schema,
});
};
export const getIsQueryOrMutation = (queryString: string) => {
return queryString.replace(/\s/g, '').startsWith('query')
? 'query'
: 'mutate';
};
@warrenday
warrenday / linked-list-iterator.js
Last active February 17, 2021 20:44
Loop over a linked list
class LinkedList {
head = null
tail = null;
insert(data) {
const newNode = { data };
if (!this.head) {
this.head = newNode
} else {
this.tail.next = newNode;