Created
April 12, 2018 15:43
-
-
Save jbaxleyiii/fac68c4b57117adf8a79d85e78a55627 to your computer and use it in GitHub Desktop.
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 { ApolloConsumer } from 'react-apollo'; | |
import Link from './Link'; | |
const FilterLink = ({ filter, children }) => ( | |
<ApolloConsumer> | |
{cache => ( | |
<Link | |
onClick={() => cache.writeData({ data: { modal: { isOpen: true } })} | |
> | |
{children} | |
</Link> | |
)} | |
</ApolloConsumer> | |
); |
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 { Query } from 'react-apollo'; | |
import gql from 'graphql-tag'; | |
import Link from './Link'; | |
const MODAL = gql`{ modal @client { isOpen } }`; | |
const FilterLink = ({ filter, children }) => ( | |
<Query query={MODAL}> | |
{({ data, client }) => ( | |
<Link | |
onClick={() => client.writeQuery({ query: MODAL, data: { modal: { isOpen: true } })} | |
> | |
{children} | |
</Link> | |
)} | |
</ApolloConsumer> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment