Skip to content

Commit

Permalink
Deprecate client:codegen command (#2619)
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-scheer authored May 20, 2022
1 parent 26b5fad commit 573ff2b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
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

0 comments on commit 573ff2b

Please sign in to comment.