Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate client:codegen command #2619

Merged
merged 2 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilled-yaks-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"apollo": minor
---

Deprecate the client:codegen command
10 changes: 1 addition & 9 deletions packages/apollo-language-server/src/graphqlTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1742,18 +1742,12 @@ export enum ValidationErrorType {
WARNING = "WARNING",
}

/**
* Filter options to exclude by client reference ID, client name, and client version.
*/
export interface ClientInfoFilter {
name?: string | null;
referenceID?: string | null;
version?: string | null;
}

/**
* This is stored with a schema when it is uploaded
*/
export interface GitContextInput {
branch?: string | null;
commit?: string | null;
Expand Down Expand Up @@ -1856,11 +1850,9 @@ export interface OperationDocumentInput {
name?: string | null;
}

/**
* Options to filter by operation name.
*/
export interface OperationNameFilterInput {
name: string;
version?: string | null;
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/apollo/src/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ export abstract class ClientCommand extends ProjectCommand {
}),
};
public project!: GraphQLClientProject;

constructor(argv, config) {
super(argv, config);
this.type = "client";
Expand Down
27 changes: 24 additions & 3 deletions packages/apollo/src/commands/client/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import chalk from "chalk";
import { Debug } from "apollo-language-server";

import { TargetType, default as generate } from "../../generate";
import { ClientCommand } from "../../Command";
import { ClientCommand, ProjectCommand } from "../../Command";

const waitForKey = async () => {
console.log("Press any key to stop.");
Expand All @@ -25,7 +25,7 @@ const waitForKey = async () => {
export default class Generate extends ClientCommand {
static aliases = ["codegen:generate"];
static description =
"Generate static types for GraphQL queries. Can use the published schema in the Apollo registry or a downloaded schema.";
"[DEPRECATED] Generate static types for GraphQL queries. Can use the published schema in the Apollo registry or a downloaded schema.";

static flags = {
...ClientCommand.flags,
Expand Down Expand Up @@ -111,6 +111,11 @@ export default class Generate extends ClientCommand {
description:
'By default, TypeScript will output "ts" files. Set "tsFileExtension" to specify a different file extension, for example "d.ts"',
}),

suppressDeprecationWarning: flags.boolean({
description:
"Silence the deprecation warning output by the codegen command",
}),
};

static args = [
Expand All @@ -125,12 +130,28 @@ export default class Generate extends ClientCommand {
},
];

DEPRECATION_MSG =
"\n--------------------------------------------------------------------------------\n" +
"DEPRECATED: This command will be removed from the `apollo` CLI in \n" +
"its next major version. Replacement functionality is available via \n" +
"the `graphql-code-generator` project: https://www.graphql-code-generator.com/\n" +
"This message can be suppressed with the --suppressDeprecationWarning flag.\n" +
"--------------------------------------------------------------------------------\n";

protected printDeprecationWarning() {
console.error(this.DEPRECATION_MSG);
}

async run() {
const {
flags: { watch },
flags: { watch, suppressDeprecationWarning },
args: { output },
} = this.parse(Generate);

if (!suppressDeprecationWarning) {
this.printDeprecationWarning();
}

let write;
const run = () =>
this.runTasks(({ flags, args, project, config }) => {
Expand Down