diff --git a/.changeset/chilled-yaks-refuse.md b/.changeset/chilled-yaks-refuse.md new file mode 100644 index 0000000000..1c95ccf621 --- /dev/null +++ b/.changeset/chilled-yaks-refuse.md @@ -0,0 +1,5 @@ +--- +"apollo": minor +--- + +Deprecate the client:codegen command diff --git a/packages/apollo-language-server/src/graphqlTypes.ts b/packages/apollo-language-server/src/graphqlTypes.ts index ec95632ad7..5cd49bd2bb 100644 --- a/packages/apollo-language-server/src/graphqlTypes.ts +++ b/packages/apollo-language-server/src/graphqlTypes.ts @@ -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; @@ -1856,11 +1850,9 @@ export interface OperationDocumentInput { name?: string | null; } -/** - * Options to filter by operation name. - */ export interface OperationNameFilterInput { name: string; + version?: string | null; } /** diff --git a/packages/apollo/src/Command.ts b/packages/apollo/src/Command.ts index 1a832f6af8..5e1bda4505 100644 --- a/packages/apollo/src/Command.ts +++ b/packages/apollo/src/Command.ts @@ -345,6 +345,7 @@ export abstract class ClientCommand extends ProjectCommand { }), }; public project!: GraphQLClientProject; + constructor(argv, config) { super(argv, config); this.type = "client"; diff --git a/packages/apollo/src/commands/client/codegen.ts b/packages/apollo/src/commands/client/codegen.ts index 1981640f8e..96b64a0248 100644 --- a/packages/apollo/src/commands/client/codegen.ts +++ b/packages/apollo/src/commands/client/codegen.ts @@ -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."); @@ -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, @@ -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 = [ @@ -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 }) => {