Skip to content
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
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
## Upcoming

- `apollo`
- <First `apollo` related entry goes here>
- https://github.com/apollographql/apollo-tooling/pull/1849
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting of this entry isn’t consistent with what we have but I’m not concerned too much there, and that’s non blocking. I can amend before releasing since I’ll have to do that anyway

- Update all commands that supported --tag to prefer --variant and indicate a deprecation warning for --tag
- All usages of --tag will continue to work
- The two flags cannot be used in tandem (i.e. --variant replaces --tag)
- --tag will no longer appear in help messages
- Updates of --help messages
- Bug fix of some apollo commands that did not work with `graph@variant` parsing within the apollo.config.js
- Improved error messaging when a graph is not specified in either `apollo.config.js` or within the API key.
- `apollo-codegen-flow`
- <First `apollo-codegen-flow` related entry goes here>
- `apollo-codegen-scala`
Expand Down
16 changes: 8 additions & 8 deletions packages/apollo-language-server/src/config/__tests__/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ describe("ApolloConfig", () => {
});
});

describe("tag", () => {
it("gets default tag when none is set", () => {
describe("variant", () => {
it("gets default variant when none is set", () => {
const config = new ApolloConfig({ client: { service: "hai" } });
expect(config.tag).toEqual("current");
expect(config.variant).toEqual("current");
});

it("gets tag from service specifier", () => {
it("gets variant from service specifier", () => {
const config = new ApolloConfig({ client: { service: "hai@master" } });
expect(config.tag).toEqual("master");
expect(config.variant).toEqual("master");
});

it("can set and override tags", () => {
it("can set and override variants", () => {
const config = new ApolloConfig({ client: { service: "hai@master" } });
config.tag = "new";
expect(config.tag).toEqual("new");
config.variant = "new";
expect(config.variant).toEqual("new");
});
});

Expand Down
10 changes: 5 additions & 5 deletions packages/apollo-language-server/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class ApolloConfig {
public name?: string;
public service?: ServiceConfigFormat;
public client?: ClientConfigFormat;
private _tag?: string;
private _variant?: string;

constructor(public rawConfig: ApolloConfigFormat, public configURI?: URI) {
this.isService = !!rawConfig.service;
Expand All @@ -162,12 +162,12 @@ export class ApolloConfig {
return configs;
}

set tag(tag: string) {
this._tag = tag;
set variant(tag: string) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern is if this breaks anything in vs code. But I don’t think it should

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admit I didn't test with VS code, but mainly because I don't know how to test a local build! Is there a QA practice we go through before release?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in a consistent way! I’ll run through all this before releasing, but I don’t expect any issue here since it only interfaces with the language server anyway :)

this._variant = tag;
}

get tag(): string {
if (this._tag) return this._tag;
get variant(): string {
if (this._variant) return this._variant;
let tag: string = "current";
if (this.client && typeof this.client.service === "string") {
const specifierTag = parseServiceSpecifier(this.client
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-language-server/src/project/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class GraphQLClientProject extends GraphQLProject {
client: totalTypes - serviceTypes,
total: totalTypes
},
tag: this.config.tag,
tag: this.config.variant,
loaded: Boolean(this.schema || this.serviceSchema),
lastFetch: this.lastLoadDate
};
Expand All @@ -202,7 +202,7 @@ export class GraphQLClientProject extends GraphQLProject {
(async () => {
this.serviceSchema = augmentSchemaWithGeneratedSDLIfNeeded(
await this.schemaProvider.resolveSchema({
tag: tag || this.config.tag,
tag: tag || this.config.variant,
force: true
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import gql from "graphql-tag";
import { GraphQLSchema, buildClientSchema } from "graphql";
import { ApolloEngineClient, ClientIdentity } from "../../engine";
import { ClientConfig, parseServiceSpecifier } from "../../config";
import { getServiceFromKey, isServiceKey } from "../../config/utils";
import { getServiceFromKey, isServiceKey } from "../../config";
import {
GraphQLSchemaProvider,
SchemaChangeUnsubscribeHandler,
Expand Down
27 changes: 21 additions & 6 deletions packages/apollo/src/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { WithRequired, DeepPartial } from "apollo-env";
import { OclifLoadingHandler } from "./OclifLoadingHandler";
import URI from "vscode-uri";
import { tagFlagDeprecatedWarning } from "./utils/sharedMessages";

const { version, referenceID } = require("../package.json");

Expand All @@ -36,6 +37,7 @@ export interface Flags {
engine?: string;
frontend?: string;
tag?: string;
variant?: string;
skipSSLValidation?: boolean;
}

Expand Down Expand Up @@ -76,18 +78,19 @@ export abstract class ProjectCommand extends Command {
"Additional header to send to server for introspectionQuery. May be used multiple times to add multiple headers. NOTE: The `--endpoint` flag is REQUIRED if using the `--header` flag."
}),
endpoint: flags.string({
description: "The url of your service"
description: "The URL for the CLI use to introspect your service"
}),
key: flags.string({
description: "The API key for the Apollo Engine service",
description:
"The API key to use for authentication to Apollo Graph Manager",
default: () => process.env.ENGINE_API_KEY
}),
engine: flags.string({
description: "Reporting URL for a custom Apollo Engine deployment",
description: "URL for a custom Apollo Graph Manager deployment",
hidden: true
}),
frontend: flags.string({
description: "URL for a custom Apollo Engine frontend",
description: "URL for a custom Apollo Graph Manager frontend",
hidden: true
})
};
Expand Down Expand Up @@ -143,7 +146,10 @@ export abstract class ProjectCommand extends Command {
return;
}

config.tag = flags.tag || config.tag || "current";
config.variant = flags.variant || flags.tag || config.variant;
if (flags.tag) {
console.warn(tagFlagDeprecatedWarning);
}
// flag overrides
config.setDefaults({
engine: {
Expand Down Expand Up @@ -281,7 +287,16 @@ export abstract class ClientCommand extends ProjectCommand {
}),
tag: flags.string({
char: "t",
description: "The published service tag for this client"
description:
"[Deprecated: please use --variant instead] The tag (AKA variant) of the graph in Apollo Graph Manager to associate this client to",
hidden: true,
exclusive: ["variant"]
}),
variant: flags.string({
char: "v",
description:
"The variant of the graph in Apollo Graph Manager to associate this client to",
exclusive: ["tag"]
}),
queries: flags.string({
description: "Deprecated in favor of the includes flag"
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo/src/commands/client/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { relative } from "path";
import { graphqlTypes } from "apollo-language-server";
import chalk from "chalk";
import envCi from "env-ci";
import { graphUndefinedError } from "../../utils/errors";
import { graphUndefinedError } from "../../utils/sharedMessages";

const { ValidationErrorType } = graphqlTypes;
type ValidationResult = graphqlTypes.ValidateOperations_service_validateOperations_validationResults;
Expand Down Expand Up @@ -60,7 +60,7 @@ export default class ClientCheck extends ClientCommand {

ctx.validationResults = await project.engine.validateOperations({
id: config.name,
tag: config.tag,
tag: config.variant,
operations: ctx.operations.map(({ body, name }) => ({
body,
name
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo/src/commands/client/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class Generate extends ClientCommand {

let write;
const run = () =>
this.runTasks(({ flags, args, project }) => {
this.runTasks(({ flags, args, project, config }) => {
let inferredTarget: TargetType = "" as TargetType;
if (
["json", "swift", "typescript", "flow", "scala"].includes(
Expand Down Expand Up @@ -172,7 +172,7 @@ export default class Generate extends ClientCommand {
task: async (ctx, task) => {
task.title = `Generating query files with '${inferredTarget}' target`;
const schema = await project.resolveSchema({
tag: flags.tag
tag: config.variant
});

if (!schema) throw new Error("Error loading schema");
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo/src/commands/client/download-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export default class SchemaDownload extends ClientCommand {
];

async run() {
await this.runTasks(({ args, project, flags }) => {
await this.runTasks(({ args, project, flags, config }) => {
const extension = args.output.split(".").pop();
const isSDLFormat = ["graphql", "graphqls", "gql"].includes(extension);
return [
{
title: `Saving schema to ${args.output}`,
task: async () => {
const schema = await project.resolveSchema({ tag: flags.tag });
const schema = await project.resolveSchema({ tag: config.variant });
const formattedSchema = isSDLFormat
? printSchema(schema)
: JSON.stringify(introspectionFromSchema(schema), null, 2);
Expand Down
6 changes: 3 additions & 3 deletions packages/apollo/src/commands/client/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ApolloConfig,
graphqlTypes
} from "apollo-language-server";
import { graphUndefinedError } from "../../utils/errors";
import { graphUndefinedError } from "../../utils/sharedMessages";

export default class ClientPush extends ClientCommand {
static description =
Expand Down Expand Up @@ -53,7 +53,7 @@ export default class ClientPush extends ClientCommand {
},
{
title: `Checked operations against ${chalk.cyan(
config.name + "@" + config.tag
config.name + "@" + config.variant
)}`,
task: async () => {}
},
Expand Down Expand Up @@ -87,7 +87,7 @@ export default class ClientPush extends ClientCommand {
id: config.name,
operations: operationManifest,
manifestVersion: 2,
graphVariant: config.tag
graphVariant: config.variant
};
const { operations: _op, ...restVariables } = variables;
this.debug("Variables sent to Apollo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ exports[`service:check integration federated should report composition errors co
exports[`service:check integration federated should report composition errors correctly --markdown 1`] = `
"
### Apollo Service Check
🔄 Validated graph composition on schema tag \`master\` for service \`accounts\` on graph \`engine\`.
🔄 Validated graph composition for service \`accounts\` on graph \`engine@master\`.
❌ Found **3 composition errors**

| Service | Field | Message |
Expand All @@ -115,7 +115,7 @@ exports[`service:check integration federated should report composition errors co

exports[`service:check integration federated should report composition errors correctly compacts output in CI 1`] = `
"Loading Apollo Project
Found 3 graph composition errors for service accounts on graph engine
Found 3 graph composition errors for service accounts on graph engine@master

╔══════════╤═════════╤════════════════════════════════════════════════════╗
║ Service │ Field │ Message ║
Expand All @@ -134,11 +134,11 @@ Found 3 graph composition errors for service accounts on graph engine
exports[`service:check integration federated should report composition errors correctly vanilla 1`] = `
"Loading Apollo Project [started]
Loading Apollo Project [completed]
Validate graph composition for service accounts on graph engine [started]
Validate graph composition for service accounts on graph engine@master [started]
→ Fetching local service's partial schema
→ Attempting to compose graph with accounts service's partial schema
Found 3 graph composition errors for service accounts on graph engine [title changed]
Found 3 graph composition errors for service accounts on graph engine [failed]
Found 3 graph composition errors for service accounts on graph engine@master [title changed]
Found 3 graph composition errors for service accounts on graph engine@master [failed]
→ Federated service composition was unsuccessful. Please see the reasons below.

╔══════════╤═════════╤════════════════════════════════════════════════════╗
Expand Down Expand Up @@ -178,7 +178,7 @@ exports[`service:check integration federated should report composition success c
exports[`service:check integration federated should report composition success correctly --markdown 1`] = `
"
### Apollo Service Check
🔄 Validated your local schema against schema tag \`master\` for service \`accounts\` on graph \`engine\`.
🔄 Validated your local schema against metrics from variant \`master\` for graph \`accounts\` on graph \`engine@master\`.
🔢 Compared **1 schema change** against **0 operations** seen over the **last 548 days**.
✅ Found **no breaking changes**.

Expand All @@ -189,7 +189,7 @@ exports[`service:check integration federated should report composition success c

exports[`service:check integration federated should report composition success correctly compacts output in CI 1`] = `
"Loading Apollo Project
Found 0 graph composition errors for service accounts on graph engine
Found 0 graph composition errors for service accounts on graph engine@master
Compared 1 schema change against 0 operations over the last 548 days
Found 0 breaking changes and 1 compatible change
╔════════╤══════════════════╤═══════════════════════════════════════════════════════════════════════════════╗
Expand All @@ -206,11 +206,11 @@ View full details at: https://engine-staging.apollographql.com/service/justin-fu
exports[`service:check integration federated should report composition success correctly vanilla 1`] = `
"Loading Apollo Project [started]
Loading Apollo Project [completed]
Validate graph composition for service accounts on graph engine [started]
Validate graph composition for service accounts on graph engine@master [started]
→ Fetching local service's partial schema
→ Attempting to compose graph with accounts service's partial schema
Found 0 graph composition errors for service accounts on graph engine [title changed]
Found 0 graph composition errors for service accounts on graph engine [completed]
Found 0 graph composition errors for service accounts on graph engine@master [title changed]
Found 0 graph composition errors for service accounts on graph engine@master [completed]
Comparing schema changes [started]
Compared 1 schema change against 0 operations over the last 548 days [title changed]
Compared 1 schema change against 0 operations over the last 548 days [completed]
Expand Down Expand Up @@ -251,7 +251,7 @@ exports[`service:check integration non-federated should report traffic errors co
exports[`service:check integration non-federated should report traffic errors correctly --markdown 1`] = `
"
### Apollo Service Check
🔄 Validated your local schema against schema tag \`master\` on graph \`engine\`.
🔄 Validated your local schema against metrics from variant \`master\` on graph \`engine@master\`.
🔢 Compared **1 schema change** against **0 operations** seen over the **last 548 days**.
❌ Found **1 breaking change** that would affect **0 operations** across **0 clients**

Expand All @@ -263,11 +263,11 @@ exports[`service:check integration non-federated should report traffic errors co
exports[`service:check integration non-federated should report traffic errors correctly vanilla 1`] = `
"Loading Apollo Project [started]
Loading Apollo Project [completed]
Validating schema against tag master on graph engine [started]
Validating schema against metrics from variant master on graph engine@master [started]
→ Resolving schema
→ Validating schema
Validated schema against tag master on graph engine [title changed]
Validated schema against tag master on graph engine [completed]
Validated schema against metrics from variant master on graph engine@master [title changed]
Validated schema against metrics from variant master on graph engine@master [completed]
Comparing schema changes [started]
Compared 1 schema change against 0 operations over the last 548 days [title changed]
Compared 1 schema change against 0 operations over the last 548 days [completed]
Expand Down Expand Up @@ -309,7 +309,7 @@ exports[`service:check integration non-federated should report traffic non-error
exports[`service:check integration non-federated should report traffic non-errors correctly --markdown 1`] = `
"
### Apollo Service Check
🔄 Validated your local schema against schema tag \`master\` on graph \`engine\`.
🔄 Validated your local schema against metrics from variant \`master\` on graph \`engine@master\`.
🔢 Compared **1 schema change** against **0 operations** seen over the **last 548 days**.
✅ Found **no breaking changes**.

Expand All @@ -321,11 +321,11 @@ exports[`service:check integration non-federated should report traffic non-error
exports[`service:check integration non-federated should report traffic non-errors correctly vanilla 1`] = `
"Loading Apollo Project [started]
Loading Apollo Project [completed]
Validating schema against tag master on graph engine [started]
Validating schema against metrics from variant master on graph engine@master [started]
→ Resolving schema
→ Validating schema
Validated schema against tag master on graph engine [title changed]
Validated schema against tag master on graph engine [completed]
Validated schema against metrics from variant master on graph engine@master [title changed]
Validated schema against metrics from variant master on graph engine@master [completed]
Comparing schema changes [started]
Compared 1 schema change against 0 operations over the last 548 days [title changed]
Compared 1 schema change against 0 operations over the last 548 days [completed]
Expand All @@ -346,7 +346,7 @@ View full details at: https://engine-staging.apollographql.com/service/justin-fu
exports[`service:check markdown formatting is correct with breaking changes 1`] = `
"
### Apollo Service Check
🔄 Validated your local schema against schema tag \`staging\` on graph \`engine\`.
🔄 Validated your local schema against metrics from variant \`staging\` on graph \`engine@staging\`.
🔢 Compared **18 schema changes** against **100 operations** seen over the **last 24 hours**.
❌ Found **7 breaking changes** that would affect **3 operations** across **2 clients**

Expand All @@ -357,7 +357,7 @@ exports[`service:check markdown formatting is correct with breaking changes 1`]
exports[`service:check markdown formatting is correct with breaking changes 2`] = `
"
### Apollo Service Check
🔄 Validated your local schema against schema tag \`staging\` on graph \`engine\`.
🔄 Validated your local schema against metrics from variant \`staging\` on graph \`engine@staging\`.
🔢 Compared **1 schema change** against **1 operation** seen over the **last 24 hours**.
❌ Found **1 breaking change** that would affect **1 operation** across **1 client**

Expand All @@ -368,7 +368,7 @@ exports[`service:check markdown formatting is correct with breaking changes 2`]
exports[`service:check markdown formatting is correct with no breaking changes 1`] = `
"
### Apollo Service Check
🔄 Validated your local schema against schema tag \`staging\` on graph \`engine\`.
🔄 Validated your local schema against metrics from variant \`staging\` on graph \`engine@staging\`.
🔢 Compared **1 schema change** against **100 operations** seen over the **last 24 hours**.
✅ Found **no breaking changes**.

Expand All @@ -379,7 +379,7 @@ exports[`service:check markdown formatting is correct with no breaking changes 1
exports[`service:check markdown formatting is correct with no changes 1`] = `
"
### Apollo Service Check
🔄 Validated your local schema against schema tag \`staging\` on graph \`engine\`.
🔄 Validated your local schema against metrics from variant \`staging\` on graph \`engine@staging\`.

✅ Found **no changes**.

Expand Down
Loading