Skip to content

Instantly share code, notes, and snippets.

View jbaxleyiii's full-sized avatar
💼
Moved to management

James Baxley jbaxleyiii

💼
Moved to management
View GitHub Profile
import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
const GET_USER_WITH_ID = gql`
query getUser(id: $ID!) {
user { name }
}
`;
const SUBMIT_COMMENT_MUTATION = gql`
mutation submitComment($repoFullName: String!, $commentContent: String!) {
submitComment(repoFullName: $repoFullName, commentContent: $commentContent) {
postedBy {
login
html_url
}
createdAt
content
const withPollingQuery = graphql(GET_USER_WITH_ID, {
options: () => ({ pollInterval: 1000 })
});
// alternatively you can pass an object
// const withPollingQuery = graphql(GET_USER_WITH_ID, {
// options: { pollInterval: 1000 }
// });
const MyComponentWithData = withPollingQuery(MyComponent);
const withUser = graphql(GET_USER_DATA, {
options: (ownProps) => ({ skip: !ownProps.authenticated })
});
const MyComponentWithData = withUser(MyComponent);
it('executes a query', (done) => {
const query = gql` query people { allPeople(first: 1) { people { name } } }`;
const data = { allPeople: { people: [ { name: 'Luke Skywalker' } ] } };
const networkInterface = mockNetworkInterface({ request: { query }, result: { data } });
const client = new ApolloClient({ networkInterface });
const withGraphQL = graphql(query);
class Container extends Component {
@jbaxleyiii
jbaxleyiii / composition.jsx
Last active August 15, 2016 02:56
Apollo Fragment Composition
import { Component } from 'react';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
/*
GraphQL Enhancers (resuable and shareable)
Fragment Enhancers do the following:
- attach the fragment / fragments statically to the component (or a way for an operation enhancer to read)
//components/TodoApp.js
import { graphql } from 'react-apollo'
class TodoApp extends React.Component {
render () { ... }
}
const withTodos = graphql(todosQuery, {
 props({ loading, data }) {
    return { todos: data ? data.todos : [] };
import { renderToStringWithData } from "react-apollo/server"
// during request
renderToStringWithData(app).then(markup => {
// send markup to client
});
DECLARE @search AS NVARCHAR(100) = '';
DECLARE @metersPerMile AS DECIMAL = 1609.34;
DECLARE @smallGroupTypeId AS INT = 25;
DECLARE @groupEntityTypeId AS INT = (SELECT Id FROM EntityType WHERE Name = 'Rock.Model.Group');
DECLARE @tagAttributeId AS INT = 16815;
DECLARE @childcareAttributeId AS INT = 5406;
DECLARE @typeAttributeId AS INT = 16814;
DECLARE @categoryAttributeId AS INT = 1409;
IF OBJECT_ID('tempdb.dbo.#groupTags', 'U') IS NOT NULL DROP TABLE #groupTags;
SELECT g.Id AS GroupId, CONVERT(NVARCHAR(MAX), dv.Value) AS Tag, 1 as TagValue
@jbaxleyiii
jbaxleyiii / dep-speeds.md
Last active September 18, 2016 02:27
Deps in holtzmann
------------------------------------------------------------------------------------
| Dependency                                          | Time     | Size   | # Deps |
------------------------------------------------------------------------------------
| @kadira/storybook                                   | 2m 15.4s | 56 MB  | 505    |
| norma-bower                                         | 1m 59.5s | 41 MB  | 369    |
| jest                                                | 1m 27.7s | 24 MB  | 323    |
| jest-cli                                            | 1m 25.8s | 24 MB  | 323    |
| norma-meteor-run                                    | 1m 8s    | 25 MB  | 201    |
| babel-jest                                          | 33.8s    | 6.7 MB | 120    |