How to use the apollo-codegen-core/lib/utilities/array.maybePush function in apollo-codegen-core

To help you get started, we’ve selected a few apollo-codegen-core 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-tooling / packages / apollo-codegen-typescript / src / codeGeneration.ts View on Github external
acc = selections.reduce((selectionAcc, selection) => {
        switch (selection.kind) {
          case "Field":
          case "TypeCondition":
            selectionAcc = maybePush(selectionAcc, selection.type);
            break;
          case "FragmentSpread":
            selectionAcc = reduceTypesForDocument(selection, selectionAcc);
            break;
          default:
            break;
        }

        return selectionAcc;
      }, acc);
github apollographql / apollo-tooling / packages / apollo-codegen-typescript / src / codeGeneration.ts View on Github external
(acc: GraphQLType[], { type }: { type: GraphQLType }) => {
        const t = this.getUnderlyingType(type);
        if (this.isGlobalType(t)) {
          return maybePush(acc, t);
        }
        return acc;
      },
      []
github apollographql / apollo-tooling / packages / apollo-codegen-typescript / src / codeGeneration.ts View on Github external
private reduceTypesUsed = (
    acc: (GraphQLType | GraphQLOutputType)[],
    type: GraphQLType
  ) => {
    if (isNonNullType(type)) {
      type = getNullableType(type);
    }

    if (isListType(type)) {
      type = type.ofType;
    }

    if (isInputObjectType(type) || isObjectType(type)) {
      acc = maybePush(acc, type);
      const fields = type.getFields();
      acc = Object.keys(fields)
        .map(key => fields[key] && fields[key].type)
        .reduce(this.reduceTypesUsed, acc);
    } else {
      acc = maybePush(acc, type);
    }

    return acc;
  };
github apollographql / apollo-tooling / packages / apollo-codegen-typescript / src / codeGeneration.ts View on Github external
private reduceSelection = (
    acc: GraphQLType[],
    selection: Selection
  ): GraphQLType[] => {
    if (selection.kind === "Field" || selection.kind === "TypeCondition") {
      const type = this.getUnderlyingType(selection.type);
      if (this.isGlobalType(type)) {
        acc = maybePush(acc, type);
      }
    }

    if (selection.selectionSet) {
      return selection.selectionSet.selections.reduce(
        this.reduceSelection,
        acc
      );
    }

    return acc;
  };
github apollographql / apollo-tooling / packages / apollo-codegen-typescript / src / codeGeneration.ts View on Github external
if (isNonNullType(type)) {
      type = getNullableType(type);
    }

    if (isListType(type)) {
      type = type.ofType;
    }

    if (isInputObjectType(type) || isObjectType(type)) {
      acc = maybePush(acc, type);
      const fields = type.getFields();
      acc = Object.keys(fields)
        .map(key => fields[key] && fields[key].type)
        .reduce(this.reduceTypesUsed, acc);
    } else {
      acc = maybePush(acc, type);
    }

    return acc;
  };