How to use the apollo-utilities.isIdValue function in apollo-utilities

To help you get started, we’ve selected a few apollo-utilities 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 apollographql / apollo-client / packages / apollo-cache-inmemory / src / readFromStore.ts View on Github external
function addPreviousResultToIdValues(value: any, previousResult: any): any {
  // If the value is an `IdValue`, add the previous result to it whether or not that
  // `previousResult` is undefined.
  //
  // If the value is an array, recurse over each item trying to add the `previousResult` for that
  // item.
  if (isIdValue(value)) {
    return {
      ...value,
      previousResult,
    };
  } else if (Array.isArray(value)) {
    const idToPreviousResult: { [id: string]: any } = {};

    // If the previous result was an array, we want to build up our map of ids to previous results
    // using the private `ID_KEY` property that is added in `resultMapper`.
    if (Array.isArray(previousResult)) {
      previousResult.forEach(item => {
        // item can be null
        if (item && item[ID_KEY]) {
          idToPreviousResult[item[ID_KEY]] = item;
        }
      });
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / readFromStore.ts View on Github external
export function assertIdValue(idValue: IdValue) {
  invariant(isIdValue(idValue), `\
Encountered a sub-selection on the query, but the store doesn't have \
an object reference. This should never happen during normal use unless you have custom code \
that is directly manipulating the store; please file an issue.`);
}
github Grantimus9 / vuegraphqlphx / assets / node_modules / apollo-cache-inmemory / lib / readFromStore.js View on Github external
export function assertIdValue(idValue) {
    if (!isIdValue(idValue)) {
        throw new Error("Encountered a sub-selection on the query, but the store doesn't have an object reference. This should never happen during normal use unless you have custom code that is directly manipulating the store; please file an issue.");
    }
}
function addPreviousResultToIdValues(value, previousResult) {
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / readFromStore.ts View on Github external
function assertSelectionSetForIdValue(
  field: FieldNode,
  value: any,
) {
  if (!field.selectionSet && isIdValue(value)) {
    throw new InvariantError(
      `Missing selection set for object of type ${
        value.typename
      } returned for query field ${field.name.value}`
    );
  }
}
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / readFromStore.ts View on Github external
export function assertIdValue(idValue: IdValue) {
  if (!isIdValue(idValue)) {
    throw new Error(`Encountered a sub-selection on the query, but the store doesn't have \
an object reference. This should never happen during normal use unless you have custom code \
that is directly manipulating the store; please file an issue.`);
  }
}
github Grantimus9 / vuegraphqlphx / assets / node_modules / apollo-cache-inmemory / lib / writeToStore.js View on Github external
Object.keys(generated).forEach(function (key) {
        var value = generated[key];
        var realValue = real[key];
        if (isIdValue(value) && isGeneratedId(value.id) && isIdValue(realValue)) {
            mergeWithGenerated(value.id, realValue.id, cache);
        }
        cache.delete(generatedKey);
        cache.set(realKey, __assign({}, generated, real));
    });
}
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / writeToStore.ts View on Github external
Object.keys(generated).forEach(key => {
    const value = generated[key];
    const realValue = real[key];

    if (
      isIdValue(value) &&
      isGeneratedId(value.id) &&
      isIdValue(realValue) &&
      !isEqual(value, realValue) &&
      mergeWithGenerated(value.id, realValue.id, cache)
    ) {
      madeChanges = true;
    }
  });
github Grantimus9 / vuegraphqlphx / assets / node_modules / apollo-cache-inmemory / lib / writeToStore.js View on Github external
writeSelectionSetToStore({
                dataId: valueDataId,
                result: value,
                selectionSet: field.selectionSet,
                context: context,
            });
        }
        storeValue = {
            type: 'id',
            id: valueDataId,
            generated: generated,
        };
        storeObject = store.get(dataId);
        if (storeObject && storeObject[storeFieldName] !== storeValue) {
            var escapedId = storeObject[storeFieldName];
            if (isIdValue(storeValue) &&
                storeValue.generated &&
                isIdValue(escapedId) &&
                !escapedId.generated) {
                throw new Error("Store error: the application attempted to write an object with no provided id" +
                    (" but the store already contains an id of " + escapedId.id + " for this object. The selectionSet") +
                    " that was trying to be written is:\n" +
                    print(field));
            }
            if (isIdValue(escapedId) && escapedId.generated) {
                generatedKey = escapedId.id;
                shouldMerge = true;
            }
        }
    }
    var newStoreObj = __assign({}, store.get(dataId), (_b = {}, _b[storeFieldName] = storeValue, _b));
    if (shouldMerge) {
github Grantimus9 / vuegraphqlphx / assets / node_modules / apollo-cache-inmemory / lib / writeToStore.js View on Github external
id: valueDataId,
            generated: generated,
        };
        storeObject = store.get(dataId);
        if (storeObject && storeObject[storeFieldName] !== storeValue) {
            var escapedId = storeObject[storeFieldName];
            if (isIdValue(storeValue) &&
                storeValue.generated &&
                isIdValue(escapedId) &&
                !escapedId.generated) {
                throw new Error("Store error: the application attempted to write an object with no provided id" +
                    (" but the store already contains an id of " + escapedId.id + " for this object. The selectionSet") +
                    " that was trying to be written is:\n" +
                    print(field));
            }
            if (isIdValue(escapedId) && escapedId.generated) {
                generatedKey = escapedId.id;
                shouldMerge = true;
            }
        }
    }
    var newStoreObj = __assign({}, store.get(dataId), (_b = {}, _b[storeFieldName] = storeValue, _b));
    if (shouldMerge) {
        mergeWithGenerated(generatedKey, storeValue.id, store);
    }
    storeObject = store.get(dataId);
    if (!storeObject || storeValue !== storeObject[storeFieldName]) {
        store.set(dataId, newStoreObj);
    }
    var _b;
}
function processArrayValue(value, generatedId, selectionSet, context) {