withGraphQL, withQueries & withMutations basic HOCs

import { graphql } from 'react-apollo'

// graphql query factory
const withGraphQL = (query, data) => graphql(query, data)

export default withGraphQL


// mutations factory
// export gql mutations to adequate format
const withMutations = (gqlMutations) => {
  // render gql queries
  return (
    {
      mutations: gqlMutations,
    }
  )
}

export default withMutations


// queries factory
// export gql queries to adequate format
const withQueries = (gqlQueries) => {
  // render gql queries
  return (
    {
      queries: gqlQueries,
    }
  )
}

export default withQueries


https://github.com/helabenkhalfallah/react-apollo-redux-graphql/tree/master/src/commons/hocs

https://github.com/helabenkhalfallah/react-apollo-redux-graphql/blob/master/src/users/pages/UserListPage.jsx

 

best practices reactjs