How to use the offix-cache.isClientGeneratedId function in offix-cache

To help you get started, we’ve selected a few offix-cache 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-offline / src / offline / processors / IDProcessor.ts View on Github external
const op = entry.operation.op;
    const operationName = op.context.operationName as string;
    const optimisticResponse = op.optimisticResponse as {[key: string]: any};
    const idField = op.context.idField || "id";

    if (!result || !optimisticResponse || !optimisticResponse[operationName]) {
      return;
    }

    let clientId = optimisticResponse[operationName][idField];
    if (!clientId) {
      return;
    }
    // Ensure we dealing with string
    clientId = clientId.toString();
    if (isClientGeneratedId(optimisticResponse[operationName][idField])) {
      queue.forEach(({ operation }) => {
        if (operation.op.variables && operation.op.variables[idField] === clientId) {
         operation.op.variables[idField] = result.data && result.data[operationName][idField];
        }
      });
    }
  }
}
github aerogear / offix / packages / offix-client / src / apollo / optimisticResponseHelpers.ts View on Github external
const op = operation.op;
  const operationName = op.context.operationName as string;
  const optimisticResponse = op.optimisticResponse as {[key: string]: any};
  const idField = op.context.idField || "id";

  if (!result || !optimisticResponse || !optimisticResponse[operationName]) {
    return;
  }

  let clientId = optimisticResponse[operationName][idField];
  if (!clientId) {
    return;
  }
  // Ensure we dealing with string
  clientId = clientId.toString();
  if (isClientGeneratedId(optimisticResponse[operationName][idField])) {
    queue.forEach((entry) => {
      if (entry.operation.op.variables && entry.operation.op.variables[idField] === clientId) {
       entry.operation.op.variables[idField] = result.data && result.data[operationName][idField];
      }
    });
  }
}
github aerogear / offix / packages / offix-offline / src / offline / OperationQueueEntry.ts View on Github external
public hasClientId() {
    return isClientGeneratedId(this.variables[this.idField as string]);
  }

offix-cache

GraphQL Mutation and Subscription Helpers

Apache-2.0
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis

Similar packages