aerogear / offix

GraphQL Offline Client and Server
https://offix.dev
Apache License 2.0
758 stars 45 forks source link

Create separate react based package that provides out of the box offline components #31

Closed wtrocki closed 4 years ago

wtrocki commented 5 years ago

Feature Request

React integration is needed to deliver better UX. We can have separate components like OfflineMutation etc.

Looking for feedback.

evelant commented 5 years ago

While I don't have a ton of experience with apollo-client yet I would hope we can make a HOC version along with a component version. IMO using a component with render props is really messy syntax wise and it mixes your data handling and presentational code in a way that is not desirable (harder to read and maintain, tightly coupled). Syntax is cleaner and concerns are better separated with a HOC in my opinion. Also from what I've seen so far Typescript appears difficult with the component version, type is never inferred on the props passed to render function.

wtrocki commented 5 years ago

Couple people raised their interest in this. Lets see if I can quickly hack something

darahayes commented 5 years ago

I've spent some time today researching options for this. React hooks were introduced earlier this year and are quickly gaining popularity as an alternative to HOCs for building stateful components. react-apollo-hooks which is soon being moved to @apollo/react-hooks is a great example of how hooks can be used with Apollo Client for a really nice developer experience.

Ideally our OfflineClient should be already compatible with the HOCs provided by react-apollo and with react-apollo-hooks for regular Mutations, Queries, Subscriptions. (Although a bit of testing is probably required)

To support the offline cases, the useMutation hook could be a great reference/starting point for implementing our own useOfflineMutation hook that would achieve the similar functionality but with the added ability to surface the various offline and conflict states from offix.

I'd love work on a prototype for this. I think one of our first steps could be to get some small sample application built with react that we can use for prototyping these ideas. (cc @wtrocki)

wtrocki commented 5 years ago

I think we need to make decision if we do sample application inside offix or use https://github.com/aerogear/offix-react-example repository. Then we can use it for investigation and supporting different flavours.

wtrocki commented 4 years ago

Fixed