Skip to content

Instantly share code, notes, and snippets.

View larkintuckerllc's full-sized avatar

John Tucker larkintuckerllc

View GitHub Profile
@larkintuckerllc
larkintuckerllc / MyApplication.java
Created December 1, 2017 16:12
How-to Dagger 2 with Android: Part 3 - 15
...
static public AuthComponent plusAuthComponent() {
if (sAuthComponent == null) {
sAuthComponent = sAppComponent.plusAuthComponent();
}
return sAuthComponent;
}
...
@larkintuckerllc
larkintuckerllc / index.js
Created June 2, 2018 09:39
Apollo Client by Example: Part 1 - 1
import { ApolloClient } from 'apollo-client';
import { withClientState } from 'apollo-link-state';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { ApolloProvider } from 'react-apollo';
import React from 'react';
import ReactDOM from 'react-dom';
import defaults from './graphql/defaults';
import resolvers from './graphql/resolvers';
import typeDefs from './graphql/typeDefs';
import './index.css';
@larkintuckerllc
larkintuckerllc / resolvers.js
Created June 2, 2018 09:52
Apollo Client by Example: Part 1 - 2
export default {};
@larkintuckerllc
larkintuckerllc / defaults.js
Created June 2, 2018 09:57
Apollo Client by Example: Part 1 - 3
export default {
counter: 0,
};
@larkintuckerllc
larkintuckerllc / typeDefs.js
Created June 2, 2018 10:12
Apollo Client by Example: Part 1 - 4
export default `
type Query {
counter: Int
}
`;
@larkintuckerllc
larkintuckerllc / App.js
Created June 2, 2018 13:52
GraphQL and Apollo Client by Example: Part 2 - 1
...
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
<Counter />
</div>
...
@larkintuckerllc
larkintuckerllc / Counter.jsx
Created June 2, 2018 14:49
GraphQL and Apollo Client by Example: Part 2 - 2
import gql from 'graphql-tag';
import { PropTypes } from 'prop-types';
import React from 'react';
import { Query } from 'react-apollo';
const CounterView = ({ counter }) => (
<div>{counter}</div>
);
CounterView.propTypes = {
@larkintuckerllc
larkintuckerllc / Counter.jsx
Created June 2, 2018 16:28
GraphQL and Apollo Client by Example: Part 2 - 3
import gql from 'graphql-tag';
import { PropTypes } from 'prop-types';
import React from 'react';
import { Query } from 'react-apollo';
const CounterView = ({ counter, onDecrement, onIncrement }) => (
<div>
<div>{counter}</div>
<button onClick={onDecrement}>-</button>
<button onClick={onIncrement}>+</button>
@larkintuckerllc
larkintuckerllc / typeDefs.js
Created June 3, 2018 00:53
GraphQL and Apollo Client by Example: Part 3 - 1
export default `
type Query {
counter: Int
}
type Mutation {
decrementCounter(unused: Boolean): Int
incrementCounter(unused: Boolean): Int
}
`;
@larkintuckerllc
larkintuckerllc / resolvers.js
Created June 3, 2018 01:09
GraphQL and Apollo Client by Example: Part 3 - 2
import gql from 'graphql-tag';
const query = gql`
{
counter @client
}
`;
export default {
Mutation: {