How to use the apollo-utilities.isField 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
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 {
        let fragment: InlineFragmentNode | FragmentDefinitionNode;

        if (isInlineFragment(selection)) {
          fragment = selection;
        } else {
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / executeStoreQuery.ts View on Github external
selectionSet.selections.forEach(selection => {
    if (!shouldInclude(selection, variables)) {
      // Skip this entirely
      return;
    }

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

      if (typeof fieldResult !== 'undefined') {
        merge(finalResult.result, {
          [resultKeyNameFromField(selection)]: fieldResult,
        });
      }

    } else {
      let fragment: InlineFragmentNode | FragmentDefinitionNode;

      if (isInlineFragment(selection)) {
        fragment = selection;
      } else {
        // This is a named fragment
        fragment = fragmentMap[selection.name.value];
github apollographql / apollo-client / packages / apollo-client / src / core / LocalState.ts View on Github external
const execute = async (selection: SelectionNode): Promise<void> => {
      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);
            }
          },
        );
      }

      let fragment: InlineFragmentNode | FragmentDefinitionNode;

      if (isInlineFragment(selection)) {
        fragment = selection;
      } else {
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);
        }
      }

      return;
    }

    let fragment: InlineFragmentNode | FragmentDefinitionNode;
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;
          let isClient = false;
          if (selection.directives && selection.directives.length) {
            // If this is a defered field we don't need to throw / warn.
            isDefered = selection.directives.some(
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);
        }
      }
    } else {
      let fragment: InlineFragmentNode | FragmentDefinitionNode;

      if (isInlineFragment(selection)) {
        fragment = selection;
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);
        }
      }
    } else {
      let fragment: InlineFragmentNode | FragmentDefinitionNode;

      if (isInlineFragment(selection)) {
        fragment = selection;
github Rsullivan00 / apollo-link-json-api / src / jsonApiLink.ts View on Github external
resultKey,
        current,
        mainDefinition,
        fragmentMap,
        node.selectionSet,
      );
    } else if (node.kind === 'FragmentSpread') {
      const fragment = fragmentMap[node.name.value];
      findRestDirectivesThenInsertNullsForOmittedFields(
        resultKey,
        current,
        mainDefinition,
        fragmentMap,
        fragment.selectionSet,
      );
    } else if (isField(node)) {
      const name = resultKeyNameFromField(node);
      if (name === resultKey && quickFindJsonApiDirective(node)) {
        // Jackpot! We found our selectionSet!
        insertNullsForAnyOmittedFields(
          current,
          mainDefinition,
          fragmentMap,
          node.selectionSet,
        );
      } else {
        findRestDirectivesThenInsertNullsForOmittedFields(
          resultKey,
          current,
          mainDefinition,
          fragmentMap,
          node.selectionSet,
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'; });
                    if (!isDefered && context.fragmentMatcherFunction) {
github Lucifier129 / graphql-dynamic / src / graphql-anywhere / index.js View on Github external
const execute = async selection => {
    if (isField(selection)) {
      const fieldResult = await executeField(selection, rootValue, execContext)

      const resultFieldKey = resultKeyNameFromField(selection)

      if (fieldResult === undefined) {
        return
      }

      return {
        type: 'field',
        key: resultFieldKey,
        value: fieldResult
      }
    }

    let fragment