Skip to content

Commit

Permalink
apollo: remove unused schemaDiff (#967)
Browse files Browse the repository at this point in the history
* apollo: remove unused schemaDiff

This removes unused and undocumented code that is a holdover from
apollo@1 and tech debt.  Since `apollo` is a commandline tool, this code
should not be used outside of Apollo's internal Platform tools, so I
suggest that the code be removed without a major version bump

* apollo: copy types and formatting into check

* apollo: add changelog for schemaDiff removal
  • Loading branch information
evans authored and trevor-scheer committed Feb 5, 2019
1 parent ce673cd commit 92ee40d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 6,801 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
- `apollo-codegen-scala`
- Generate additional case-class like APIs for data containers [#943](https://github.com/apollographql/apollo-tooling/pull/943)

- `apollo`
- remove schemaDiff and change types from code/exports [#967](https://github.com/apollographql/apollo-tooling/pull/967)

## `apollo@2.4.3`

- `apollo-env@0.3.1`
Expand Down
35 changes: 32 additions & 3 deletions packages/apollo/src/commands/service/check.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
import { flags } from "@oclif/command";
import { table } from "heroku-cli-util";
import { introspectionFromSchema } from "graphql";
import chalk from "chalk";

import { gitInfo } from "../../git";
import { ChangeType, format, SchemaChange as Change } from "../../diff";
import { ProjectCommand } from "../../Command";

// TODO These types can/should be generated from the engine schema when we
// dogfood codegen inside of the apollo-tooling repo
interface SchemaChange {
type: ChangeType;
code: string;
description: string;
}
enum ChangeType {
FAILURE = "FAILURE",
WARNING = "WARNING",
NOTICE = "NOTICE"
}

const formatChange = (change: SchemaChange) => {
let color = (x: string): string => x;
if (change.type === ChangeType.FAILURE) {
color = chalk.red;
}
if (change.type === ChangeType.WARNING) {
color = chalk.yellow;
}

return {
type: color(change.type),
code: color(change.code),
description: color(change.description)
};
};

export default class ServiceCheck extends ProjectCommand {
static aliases = ["schema:check"];
static description =
Expand Down Expand Up @@ -47,14 +76,14 @@ export default class ServiceCheck extends ProjectCommand {
const { targetUrl, diffToPrevious } = checkSchemaResult;
const { changes /*, type, validationConfig */ } = diffToPrevious;
const failures = changes.filter(
({ type }: Change) => type === ChangeType.FAILURE
({ type }: SchemaChange) => type === ChangeType.FAILURE
);

if (changes.length === 0) {
return this.log("\nNo changes present between schemas\n");
}
this.log("\n");
table(changes.map(format), {
table(changes.map(formatChange), {
columns: [
{ key: "type", label: "Change" },
{ key: "code", label: "Code" },
Expand Down
Loading

0 comments on commit 92ee40d

Please sign in to comment.