How to use the offix-conflicts-client.LocalConflictError function in offix-conflicts-client

To help you get started, we’ve selected a few offix-conflicts-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aerogear / offix / packages / offix-client / src / apollo / conflicts / baseHelpers.ts View on Github external
export function getBaseStateFromCache(
  cache: ApolloCacheWithData,
  objectState: ObjectState,
  mutationOptions: MutationOptions
): ConflictResolutionData {
  const context = mutationOptions.context;

  if (!context.conflictBase) {
    // do nothing
    const conflictBase = getObjectFromCache(cache, context.returnType, mutationOptions);
    if (conflictBase && Object.keys(conflictBase).length !== 0) {
      if (objectState.hasConflict(mutationOptions.variables, conflictBase)) {
        // 🙊 Input data is conflicted with the latest server projection
        throw new LocalConflictError(conflictBase, mutationOptions.variables);
      }
      return conflictBase;
    }
  }
}

offix-conflicts-client

adds client side conflict detection and resolution

Apache-2.0
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis

Similar packages