Advanced Topics

Logging Debug Messages

The Voyager Client uses the debug module to log debug messages.

To enable debug logs, run the following code in a browser’s console:

localStorage.debug = 'AeroGearSync:*'

Certain features can be enabled separately:

localStorage.debug = 'AeroGearSync:offlineMutates*'

Optimistic UI

By default mutations are not applied to the UI until responses are received from the server. To provide better user experience, an application may want to update the UI immediately. Optimistic response is an easy way to achieve this goal, and Voyager Client provides a helper method to work with optimistic responses:

 import { createOptimisticResponse } from "@aerogear/voyager-client";

   mutation: ADD_TASK,
   variables: item,
   optimisticResponse: createOptimisticResponse("createTask", "Task", item);

To detect if the provided data is an optimistic response, the optimisticResponse flag can be used.

The OptimisticResponse feature and the offlineQueueListener can be used together to deliver great offline experience for an application.

See the Showcase Apps section for more information.