Skip to content

Instantly share code, notes, and snippets.

View peggyrayzis's full-sized avatar
🚀
GraphQL all the things

Peggy Rayzis peggyrayzis

🚀
GraphQL all the things
View GitHub Profile
@peggyrayzis
peggyrayzis / .babelrc
Last active February 7, 2019 03:31
Webpack 2 + PWA support (Tree Shaking, Code Splitting w/ React Router v4, Service Worker)
{
"presets": [
"react",
"stage-2",
[
"env",
{
"targets": {
"browsers": [
"last 2 versions",
@peggyrayzis
peggyrayzis / style.js
Created March 27, 2017 00:06
nteract CSS in JS writeup
// Some thoughts on component structure & styling
/*
Easiest way to do themes in Aphrodite - use prop as an obj key
Each component holds their own theme info
*/
import { css, StyleSheet } from 'aphrodite'
const Button = ({ theme }) => (
import React from 'react';
import { View, Text } from 'react-native';
export default ({ title, body }) => (
<View>
<Text>{title}</Text>
<Text>{body}</Text>
</View>
);
query MatchSummary($id: String!, $season: String) {
match(id: $id) {
stats {
scores {
home {
score
isWinner: is_winner
}
away {
score
import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import { MatchSummary, NoDataSummary } from '@mls-digital/react-components';
import MatchSummaryQuery from './match-summary.graphql';
// here we're using the graphql HOC as a decorator, but you can use it as a function too!
@graphql(MatchSummaryQuery, {
options: ({ id, season, shouldPoll }) => {
return {
variables: {
import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import { MatchSummary, NoDataSummary } from '@mls-digital/react-components';
import MatchSummaryQuery from './match-summary.graphql';
const mapResultsToProps = ({ data }) => {
if (!data.match)
return {
loading: data.loading,
};
import React, { Component } from 'react';
import { compose, graphql } from 'react-apollo';
import { NoDataExtension } from '@mls-digital/react-components';
import PostGameExtension from './post-game';
import PreGameExtension from './pre-game';
import PostGameQuery from './post-game.graphql';
import PreGameQuery from './pre-game.graphql';
@compose(
graphql(PreGameQuery, {
import React, { Component } from 'react';
import { requireNativeComponent } from 'react-native';
const FloatingActionButton = requireNativeComponent(
'FloatingActionButton',
FloatingActionButtonView,
);
export default class FloatingActionButtonView extends Component {
render() {
@peggyrayzis
peggyrayzis / client.js
Last active December 21, 2017 20:09
Initializing Apollo Client with Apollo Link State
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { ApolloLink } from 'apollo-link';
import { withClientState } from 'apollo-link-state';
import { HttpLink } from 'apollo-link-http';
import { defaults, resolvers } from './resolvers/todos';
const cache = new InMemoryCache();
@peggyrayzis
peggyrayzis / todos.js
Last active December 21, 2017 20:19
Defaults for apollo-link-state
export const defaults = {
visibilityFilter: 'SHOW_ALL',
todos: [],
};