Skip to content

Instantly share code, notes, and snippets.

@ChrisMLee
ChrisMLee / Main.purs
Last active February 25, 2018 15:22
Futbol Monad + friends
module Main where
import Prelude
import App.Control.Monad (Futbol, runFutbol)
import App.Types (AppEffects, SomeEffects)
import Control.Monad.Aff.AVar (AVAR)
import Control.Monad.Aff.Console (CONSOLE)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Exception (EXCEPTION)
@ChrisMLee
ChrisMLee / index.js
Created December 17, 2017 16:25
Use Relay’s Input Object Mutations: Formatting Output Fields for Optimistic Updates
// connectionDefinitions returns a connectionType and its associated edgeType, given a node type.
const {
connectionType: VideoConnection,
edgeType: VideoEdge
} = connectionDefinitions({
nodeType: videoType,
connectionFields: () => ({
totalCount: {
type: GraphQLInt,
description: "A count of the total number of objects in this connection.",
@ChrisMLee
ChrisMLee / Component.js
Created September 30, 2017 15:51
grabbing a nested "result" property
newtype Result =
Result { goalsHomeTeam :: Number
, goalsAwayTeam :: Number
}
newtype Fixture =
Fixture { _links:: LinkGroup
, date:: String
, status:: String
, matchday:: Number
{
"name": "reactcards",
"version": "0.4.0",
"description": "devcards for react",
"license": "BSD-3-Clause",
"main": "dist/client.bundle.js",
"repository": {
"type": "git",
"url": "https://github.com/steos/reactcards.git"
},
var path = require('path')
var webpack = require('webpack')
module.exports = {
context: path.join(__dirname, "src"),
entry: {
client: './index'
},
output: {
filename: "[name].bundle.js",
@ChrisMLee
ChrisMLee / Conversation.js
Last active November 14, 2015 22:47
Mutation only updating messages for individual conversation, but not Conversations for User
createMessage(){
Relay.Store.update(new CreateMessageMutation({
user: this.props.user,
conversation: foundEdge.node,
receiverId: receiverId,
body: this.state.curText
}), {onFailure, onSuccess});
}
@ChrisMLee
ChrisMLee / PlaylistSchema.js
Created October 31, 2015 15:50
Relay Mutation - Error: "message": "Cannot read property 'id' of undefined"
exports.getPlaylistById = (root, {id}) => {
return new Promise((resolve, reject) => {
Playlist.findOne({id:id}).populate('songs').exec((err, res) => {
err ? reject(err) : resolve(res);
})
});
};
exports.addSong = ({id, youtubeLink}) => {
return new Promise((resolve, reject) => {
ListingType = GraphQL::ObjectType.define do
name "Listing"
description "Book listing by user"
global_id_field :id
field :id, !types.ID
field :user, !UserType, "if of user who owns book"
field :price, !types.Float
end