Open daniel-ac-martin opened 4 years ago
The GraphQL client from Apollo Server seems to do most of what we want. I think we should see if we can simply re-use that for now.
Apollo Client is now available.
I've not tested subscriptions yet though. (We are on an old version of apollo-server in restify so it might not work.)
If nothing else, I'd expect polling to work: https://www.apollographql.com/docs/react/data/queries/#polling
Apollo seems to suggest that subscriptions should be used sparingly: https://www.apollographql.com/docs/react/data/subscriptions/#when-to-use-subscriptions
Real applications will need to obtain data from the server in order to run.
We should provide a React component and/or hook that allows one to subscribe to a ReSTful API (or GraphQL).
Ideally, this would attempt to set up a webhook with the server so that after the initial payload the server could push any updates to the client. Polling the API according to a set interval could be used as a fall-back.
In order to support pushing updates we would need to build in support to the API endpoints so that is another thing to consider.
This sort of thing would likely benefit from Redux.