Home Provide Data from GraphQL to Redux
Reply: 1

Provide Data from GraphQL to Redux

Ramzan Chasygov
1#
Ramzan Chasygov Published in 2018-01-09 22:06:32Z

I have project, where I use redux, react-apollo and I wonder, is any chance to provide data from react-apollo to redux through reducer. Pseudo code below.

...
import { graphql } from 'react-apollo'
import gql from 'graphql-tag'

const query = gql`
{
  ...
}`

/* Function, which I want to returns data from graphql */
const getDate = () => {
  return graphql(query)
}


/*---- Reducer ----*/
export default (state = getDate(), action) => {
  console.log(state) // function, instead data
  ...
}

imranolas
2#
imranolas Reply to 2018-01-14 13:54:40Z

Something like Apollo Link Redux might help. It's intended to provide backwards compatibility for Apollo Client v1.0 apps looking to migrate to v2.0. In short it will dispatch the following actions

APOLLO_QUERY_INIT
APOLLO_QUERY_RESULT
APOLLO_MUTATION_INIT
APOLLO_MUTATION_RESULT

which you can handle in your reducers.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298413 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO