This file contains 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 { ApolloClient } from 'apollo-client'; | |
import { HttpLink, InMemoryCache, ApolloLink } from 'apollo-boost'; | |
const client = new ApolloClient({ | |
link: ApolloLink.from([ myCustomLink, new HttpLink() ]), | |
cache: new InMemoryCache() | |
}); |
This file contains 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 { render } from 'react-dom'; | |
import ApolloClient from 'apollo-boost'; | |
import { ApolloProvider } from 'react-apollo'; | |
// Pass your GraphQL endpoint to uri | |
const client = new ApolloClient({ | |
uri: 'https://nx9zvp49q7.lp.gql.zone/graphql' | |
}); |
This file contains 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 { gql } from 'apollo-boost'; | |
import { Query } from 'react-apollo'; | |
const GET_DOG = gql` | |
query { | |
dog(breed: "bulldog") { | |
id | |
displayImage | |
} |
This file contains 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 GET_USERS_ACTIVE_TODOS = gql` | |
{ | |
visibilityFilter @client | |
user(id: 1) { | |
name | |
address | |
} | |
} | |
`; |
This file contains 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 SET_VISIBILITY = gql` | |
mutation SetFilter($filter: String!) { | |
visibilityFilter(filter: $filter) @client | |
} | |
`; | |
const setVisibilityFilter = graphql(SET_VISIBILITY, { | |
props: ({ mutate, ownProps }) => ({ | |
onClick: () => mutate({ variables: { filter: ownProps.filter } }), | |
}), |
This file contains 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
export const defaults = { // same as before } | |
export const resolvers = { | |
Mutation: { | |
visibilityFilter: (_, { filter }, { cache }) => { | |
cache.writeData({ data: { visibilityFilter: filter } }); | |
return null; | |
}, | |
addTodo: (_, { text }, { cache }) => { | |
const query = gql` |
This file contains 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
export const defaults = { | |
visibilityFilter: 'SHOW_ALL', | |
todos: [], | |
}; |
This file contains 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 { 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(); |
This file contains 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, { 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, { |