Skip to content

Instantly share code, notes, and snippets.

/**
* lagRadar
* Licence: ISC copyright: @mobz 2018
*/
window.lagRadar = function lagRadar( config = {} ) {
const {
frames = 50, // number of frames to draw, more = worse performance
speed = 0.0017, // how fast the sweep moves (rads per ms)
size = 300, // outer frame px
@helfer
helfer / apollo-1-migration.md
Last active May 31, 2017 01:09
Migrating from Apollo Client 0.x to 1.0

Migrating from Apollo Client 0.x to 1.0

Here are the main breaking changes between the 0.x and 1.0 versions of Apollo Client.

fetchMore

The structure of fetchMoreResult has been changed. Previously fetchMoreResult used to contain data and loading fields, now fetchMoreResult is what fetchMoreResult.data used to be. This means your updateQueries function has to change as follows:

updateQuery: (prev, { fetchMoreResult }) => {
# mutation to add a reaction:
mutation test($input: AddReactionInput!){
addReaction(input: $input){
reaction {
content
}
}
}
# the variables (paste those in the bottom textarea)
# Autogenerated input type of AddComment
input AddCommentInput {
# A unique identifier for the client performing the mutation.
clientMutationId: String
# The Node ID of the subject to modify.
subjectId: ID!
# The contents of the comment.
body: String!
import express from 'express';
import Schema from './data/schema';
import Resolvers from './data/resolvers';
// import Mocks from './data/mocks';
import { apolloExpress, graphiqlExpress } from 'apollo-server';
import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools';
import bodyParser from 'body-parser';
const GRAPHQL_PORT = 8080;
@helfer
helfer / apollo-server-tracer.js
Last active October 22, 2016 15:30
How to instrument apollo server 0.2 with tracer
import express from 'express';
import { Tracer } from 'graphql-tracer';
import { apolloExpress } from 'apollo-server';
import Schema from './schema';
const app = express();
const tracer = new Tracer({ TRACER_APP_KEY: '...'});
addTracingToResolvers(Schema);
@helfer
helfer / apolloStoredQueries.js
Last active August 4, 2016 22:17
Using stored queries in Apollo Server
import express from 'express';
import { apolloExpress, OperationStore } from 'apollo-server';
import Schema from './schema';
const PORT = 3000;
const store = new OperationStore(Schema);
store.put('query testquery{ testString }');
const app = express();
const options = {
@helfer
helfer / apolloHAPI.js
Last active March 7, 2017 12:44
Using Apollo Server with HAPI
import hapi from 'hapi';
import graphql from 'graphql';
import { ApolloHAPI } from 'apollo-server';
const myGraphQLSchema = new graphql.GraphQLSchema({
// define your schema in GraphQL.js syntax here ...
});
const server = new hapi.Server();
import { applyDecorators } from 'graphql-tools';
import {
GraphQLSchema,
GraphQLString,
GraphQLObjectType,
} from 'graphql';
import { Doc, Log } from 'graphql-decorators';
const Logger = { log: (...args) => console.log(...args) };
// Sample GraphQL schema with decorators
+connector(storage: "MySQL")
+doc(description: "A Person")
type Person {
+mock(type: "ID")
id: Int
+mock(raw: "John")
name: String