How to use the apollo-utilities.shouldInclude 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 coralproject / talk / client / coral-framework / graphql / reduceDocument.js View on Github external
fragmentSelections.forEach((s) => {

      if (variables && !shouldInclude(s, variables)) {

        // Skip this entirely
        return;
      }

      const selName = getDefinitionID(s);
      if (!(selName in o)) {
        o[selName] = s;
        return;
      }

      o[selName] = mergeDefinitions(o[selName], s);
    });
    return o;
github apollographql / apollo-client / packages / apollo-client / src / core / LocalState.ts View on Github external
const execute = async (selection: SelectionNode): Promise => {
      if (!shouldInclude(selection, variables)) {
        // Skip this entirely.
        return;
      }

      if (isField(selection)) {
        return this.resolveField(selection, rootValue, execContext).then(
          fieldResult => {
            if (typeof fieldResult !== 'undefined') {
              resultsToMerge.push({
                [resultKeyNameFromField(selection)]: fieldResult,
              } as TData);
            }
          },
        );
      }
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / readFromStore.ts View on Github external
selectionSet.selections.forEach(selection => {
      if (!shouldInclude(selection, variables)) {
        // Skip this entirely
        return;
      }

      if (isField(selection)) {
        const fieldResult = handleMissing(
          this.executeField(object, typename, selection, execContext),
        );

        if (typeof fieldResult !== 'undefined') {
          objectsToMerge.push({
            [resultKeyNameFromField(selection)]: fieldResult,
          });
        }

      } else {
github Grantimus9 / vuegraphqlphx / assets / node_modules / graphql-anywhere / src / graphql.ts View on Github external
selectionSet.selections.forEach(selection => {
    if (!shouldInclude(selection, variables)) {
      // Skip this entirely
      return;
    }

    if (isField(selection)) {
      const fieldResult = executeField(selection, rootValue, execContext);

      const resultFieldKey = resultKeyNameFromField(selection);

      if (fieldResult !== undefined) {
        if (result[resultFieldKey] === undefined) {
          result[resultFieldKey] = fieldResult;
        } else {
          merge(result[resultFieldKey], fieldResult);
        }
      }
github apollographql / apollo-client / packages / graphql-anywhere / src / graphql.ts View on Github external
selectionSet.selections.forEach(selection => {
    if (!shouldInclude(selection, variables)) {
      // Skip this entirely
      return;
    }

    if (isField(selection)) {
      const fieldResult = executeField(selection, rootValue, execContext);

      const resultFieldKey = resultKeyNameFromField(selection);

      if (fieldResult !== undefined) {
        if (result[resultFieldKey] === undefined) {
          result[resultFieldKey] = fieldResult;
        } else {
          merge(result[resultFieldKey], fieldResult);
        }
      }
github apollographql / apollo-client / packages / graphql-anywhere / src / async.ts View on Github external
const execute = async selection => {
    if (!shouldInclude(selection, variables)) {
      // Skip this entirely
      return;
    }

    if (isField(selection)) {
      const fieldResult = await executeField(selection, rootValue, execContext);

      const resultFieldKey = resultKeyNameFromField(selection);

      if (fieldResult !== undefined) {
        if (result[resultFieldKey] === undefined) {
          result[resultFieldKey] = fieldResult;
        } else {
          merge(result[resultFieldKey], fieldResult);
        }
      }
github coralproject / talk / client / coral-framework / graphql / reduceDocument.js View on Github external
const selectionsMap = definition.selectionSet.selections.reduce((o, sel) => {
    if (variables && !shouldInclude(sel, variables)) {

      // Skip this entirely
      return o;
    }
    if (sel.kind !== 'FragmentSpread') {
      const transformed = transformDefinition(sel, execContext, path, gqlType);
      const name = getDefinitionID(sel);

      // Merge existing value.
      if (name in o) {
        o[name] = mergeDefinitions(o[name], transformed);
        return o;
      }

      o[name] = transformed;
      return o;
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / writeToStore.ts View on Github external
selectionSet.selections.forEach(selection => {
      if (!shouldInclude(selection, variables)) {
        return;
      }

      if (isField(selection)) {
        const resultFieldKey: string = resultKeyNameFromField(selection);
        const value: any = result[resultFieldKey];

        if (typeof value !== 'undefined') {
          this.writeFieldToStore({
            dataId,
            value,
            field: selection,
            context,
          });
        } else {
          let isDefered = false;
github Grantimus9 / vuegraphqlphx / assets / node_modules / apollo-cache-inmemory / lib / writeToStore.js View on Github external
selectionSet.selections.forEach(function (selection) {
        var included = shouldInclude(selection, variables);
        if (isField(selection)) {
            var resultFieldKey = resultKeyNameFromField(selection);
            var value = result[resultFieldKey];
            if (included) {
                if (typeof value !== 'undefined') {
                    writeFieldToStore({
                        dataId: dataId,
                        value: value,
                        field: selection,
                        context: context,
                    });
                }
                else {
                    var isDefered = selection.directives &&
                        selection.directives.length &&
                        selection.directives.some(function (directive) { return directive.name && directive.name.value === 'defer'; });