Skip to content

Instantly share code, notes, and snippets.

View frikille's full-sized avatar

Peter Balazs frikille

  • @flowyltd
  • London
View GitHub Profile
@frikille
frikille / exporter
Created July 17, 2013 21:22
Basic exporter for csslint.net. Exports table in to csv format and automatically downloads it.
(function exportTable() {
var table = document.getElementById('errors'),
header = 'type,line,column,title,description,browser\n',
csv,
data = [],
i, node;
for (i = 0; i < table.childNodes.length; i += 1) {
node = table.childNodes[i];
@frikille
frikille / renderer.js
Created July 19, 2015 20:30
Isomorphic renderer
import React from 'react';
import {fromJS} from 'immutable';
import ServerError from '../app/components/shared/ServerError.jsx';
class Renderer {
constructor(services, callback, req) {
this.services = services;
if (typeof callback === 'function') {
@frikille
frikille / generated-schema.js
Last active August 29, 2015 14:25
Generated GraphQL schema
import {
graphql,
GraphQLInt,
GraphQLString,
GraphQLFloat,
GraphQLBoolean,
GraphQLList,
GraphQLObjectType,
GraphQLSchema
} from 'graphql';
@frikille
frikille / schema-v2.js
Created July 19, 2015 21:11
GraphQL schema with resolve function implementation and argument
import {
graphql,
GraphQLInt,
GraphQLString,
GraphQLFloat,
GraphQLBoolean,
GraphQLList,
GraphQLNonNull,
GraphQLObjectType,
GraphQLSchema
// Getting a post with its title, author, blocks, likes and comments
post(id: 123) {
title,
author {
username,
avatar_url
},
blocks {
type,
text,
import {
graphql,
GraphQLObjectType,
GraphQLInt,
GraphQLString,
GraphQLSchema
} from 'graphql';
import PostType from './PostType.js';
import User from '../models/User.js';
import React from 'react';
import { GQLQuery } from './GQLQuery.js';
@GQLQuery
class CommentsAndLikes extends React.Component {
static queries = {
commentAndLikes() {
return `
likes {
id,
export function GQLQuery(Component) {
Component.getQuery = function (name, ...params) {
return this.queries[name].apply(this, params);
};
return Component;
}
let PostMutationType = new GraphQLObjectType({
name: 'PostType',
fields: () => ({
like: {
type: PostLikeType,
args: {
postId: {
name: 'postId',
type: GraphQLInt
}
@GQLQuery
class CommentsAndLikes extends React.Component {
static queries = {
commentAndLikes() {
return `
likes {
id,
user {
id
}