This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { Query } from 'react-apollo'; | |
import gql from "graphql-tag"; | |
const query = gql`{ | |
currencyOfInterest @client | |
}` | |
const ExchangeSelector = ({data: {rates}}) => ( | |
<Query query={query}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {makeExecutableSchema} from 'graphql-tools'; | |
const typeDefs = ` | |
type Query { | |
message(id: ID!): String! | |
} | |
type Mutation { | |
message(id: ID!): String! | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GUI engine | |
// tell the engine to switch to UCI mode | |
uci | |
// engine identify | |
id name Shredder | |
id author Stefan MK | |
// engine sends the options it can change |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const voteHandler = (postId, updown) => { | |
return new Promise((resolve, reject) => { | |
const post = posts.find(p => p.id === postId); | |
if (!post) { | |
reject(`Couldn't find post with id ${postId}`); | |
} | |
post.votes += updown; | |
resolve(post); | |
}) | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (useMethod === 'treeizedReduced') { | |
var rs = treeized(resultSet) | |
const rsr = rs.reduce((o, r) => { | |
const rc = r.categories.reduce((oo, c) => { | |
oo[c.type] = { | |
titles: c.titles.map(t => t.name) | |
} | |
return oo; | |
}, {}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const addEntities = (dataset) => { | |
dataset.forEach(d => { | |
d.title = d.title.replace(/'/, "''") | |
const stmt = | |
` | |
IF NOT EXISTS ( | |
select * from author | |
where first_name = '${d.first_name}' | |
and last_name = '${d.last_name}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Treeize from 'treeize' | |
const treeized = rs => { | |
var authors = new Treeize(); | |
const seed = rs.map(r => ({ | |
name: [r.last_name, r.first_name].join(', '), | |
'categories:type': r.category, | |
'categories:titles:name': r.title | |
})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handrolled = (rs) => { | |
const authors = {} | |
rs.forEach(r => { | |
const authname = [r.last_name, r.first_name].join(','); | |
if (!authors[authname]) { | |
authors[authname] = { | |
categories: {} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example demonstrates a simple server with some relational data: Posts and Authors. You can get the posts for a particular author, | |
// and vice-versa Read the complete docs for graphql-tools here: http://dev.apollodata.com/tools/graphql-tools/generate-schema.html | |
import { | |
makeExecutableSchema, | |
addMockFunctionsToSchema | |
} from 'graphql-tools'; | |
import { | |
schema as authorpostsSchema, |