How to use the apollo-codegen-core/lib/utilities/printing.commentBlockContent 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 / language.ts View on Github external
t.TSTypeAnnotation(type)
      );

      // TODO: Check if this works
      propertySignatureType.optional =
        keyInheritsNullability && this.isNullableType(type);

      if (this.options.useReadOnlyTypes) {
        propertySignatureType.readonly = true;
      }

      if (description) {
        propertySignatureType.leadingComments = [
          {
            type: "CommentBlock",
            value: commentBlockContent(description)
          } as t.CommentBlock
        ];
      }

      return propertySignatureType;
    });
  }
github apollographql / apollo-tooling / packages / apollo-codegen-flow / src / language.ts View on Github external
);

        // Nullable fields on input objects do not have to be defined
        // as well, so allow these fields to be "undefined"
        objectTypeProperty.optional =
          keyInheritsNullability &&
          annotation.type === "NullableTypeAnnotation";
        if (this.options.useReadOnlyTypes) {
          objectTypeProperty.variance = { kind: "plus" };
        }

        if (description) {
          objectTypeProperty.leadingComments = [
            {
              type: "CommentBlock",
              value: commentBlockContent(description)
            } as t.CommentBlock
          ];
        }

        return objectTypeProperty;
      })
    );
github apollographql / apollo-tooling / packages / apollo-codegen-typescript / src / language.ts View on Github external
public enumerationDeclaration(type: GraphQLEnumType) {
    const { name, description } = type;
    const enumMembers = sortEnumValues(type.getValues()).map(({ value }) => {
      return t.TSEnumMember(t.identifier(value), t.stringLiteral(value));
    });

    const typeAlias = t.exportNamedDeclaration(
      t.TSEnumDeclaration(t.identifier(name), enumMembers),
      []
    );

    if (description) {
      typeAlias.leadingComments = [
        {
          type: "CommentBlock",
          value: commentBlockContent(description)
        } as t.CommentBlock
      ];
    }

    return typeAlias;
  }
github apollographql / apollo-tooling / packages / apollo-codegen-flow / src / language.ts View on Github external
public exportDeclaration(
    declaration: t.Declaration,
    options: { comments?: string } = {}
  ) {
    const exportedDeclaration = t.exportNamedDeclaration(declaration, []);

    if (options.comments) {
      exportedDeclaration.trailingComments = [
        {
          type: "CommentBlock",
          value: commentBlockContent(options.comments)
        } as t.CommentBlock
      ];
    }

    return exportedDeclaration;
  }
github apollographql / apollo-tooling / packages / apollo-codegen-flow / src / language.ts View on Github external
return type;
    });

    const typeAlias = t.exportNamedDeclaration(
      t.typeAlias(
        t.identifier(name),
        undefined,
        t.unionTypeAnnotation(unionValues)
      ),
      []
    );

    typeAlias.leadingComments = [
      {
        type: "CommentBlock",
        value: commentBlockContent(description || "")
      } as t.CommentBlock
    ];

    return typeAlias;
  }
github apollographql / apollo-tooling / packages / apollo-codegen-typescript / src / language.ts View on Github external
type: this.typeFromGraphQLType(field.type)
      };
    });

    const inputType = t.exportNamedDeclaration(
      this.interface(name, fields, {
        keyInheritsNullability: true
      }),
      []
    );

    if (description) {
      inputType.leadingComments = [
        {
          type: "CommentBlock",
          value: commentBlockContent(description)
        } as t.CommentBlock
      ];
    }

    return inputType;
  }