Realtime GraphQL UI Updates in React with Apollo. ― Scotch

Realtime GraphQL UI updates in React with Apollo  #ReactJS #GraphQL

  • // ChannelsListWithData = graphql(channelsListQuery, { options: { pollInterval: 5000 a new channel from another client now updates our list of channels after 5 seconds, not the best way of doing it but a step in making the application realtime.
  • store.writeQuery({ query: channelsListQuery, data }); – } – }) – … – As soon as the mutation completes, we read the current result for the channelsListQuery out of the store, append the new channel to it, and tell Apollo Client to write it back to the store.
  • To add WebSocket support to our existing interface, we will construct a GraphQL Subscription client and merge it with our existing network interface to create a new interface that performs normal GraphQL queries over HTTP and subscription queries over WebSockets.
  • … – We edit the following part to disable const ChannelsListWithData = graphql(channelsListQuery, { options: { pollInterval: 5000 }})(ChannelsList); – … – Edit the above to: const ChannelsListWithData = to add a new channel now in our app does not reflect the changes until we refresh the page and that…
  • jsx – … – import { SubscriptionClient, addGraphQLSubscriptions } from networkInterface = createNetworkInterface({ – uri: wsClient = new { – reconnect: true – }); – – // Extend the network interface with the WebSocket – const = addGraphQLSubscriptions( – networkInterface, – wsClient – ); – To enable subscriptions throughout our…

This is the fourth and final part of a 4-part series of articles explaining the implementation of GraphQL on an Express Server and similarly in a React client using Apollo. In this article we look at how to maintain realtime UI updates after implementing different GraphQL updates that result in either creation, update or deletion of data on the server side. For part 1, 2 and 3, refer to the links:
Continue reading “Realtime GraphQL UI Updates in React with Apollo. ― Scotch”

Offline First React Native

Checkout our latest #blog post: Offline First React Native -  #ReactNative #Mobile

  • In the talk, I explained the concerns and tools related to developing React Native apps that work despite a poor connection.
  • When you want to persist data with React Native, you have 3 storage options:

    You can chose the option that best suits your unique criteria.

  • You can use React Native’s AsyncStorage to set/get items or can use Redux Persist as a performant, and easy to implement way to persist data.
  • When we are talking about data in an Offline-First mobile app, the size matters.
  • Photos are bigger in size and when you are dealing with poor connection the large data is going to be problematic.

About two weeks ago I presented a talk about the offline first React Native in the React Native Vancouver Meetup. Here is a short summary of the talk and the slides for everyone to use.
Continue reading “Offline First React Native”

Learn Relay

Learn Relay! #relayjs #reactjs

  • Relay will aggregate the defined queries with fragments by using Relay.
  • All mutations have to be dispatched using the Relay.
  • As Relay is a GraphQL client, this introduction focuses on the client side.
  • Mutations are the counterpart to queries, as they are used to modify or delete data.
  • Queries are a central part of Relay as they are used to fetch data from the GraphQL server.

Get a broad overview of the goals and prerequisites of this introduction to Relay and get to know the Pokedex app we will build together.
Continue reading “Learn Relay”