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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

- `apollo`
- Update shortlinks to use go.apollo.dev instead of bitly [#1790](https://github.com/apollographql/apollo-tooling/pull/1790)
- Support disabling literal stripping when extracting queries. [1703](https://github.com/apollographql/apollo-tooling/pull/1703)
- Fix rendering of unexpected composition errors throwing a table cell error [#1806](https://github.com/apollographql/apollo-tooling/pull/1806)
- Support disabling literal stripping when extracting queries. [1703](https://github.com/apollographql/apollo-tooling/pull/1703)
- Add ability to define schema download output path that doesn't exist yet [#1807](https://github.com/apollographql/apollo-tooling/pull/1807)
- `apollo-codegen-flow`
- Add @generated comment
- `apollo-codegen-scala`
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@types/lodash.pickby": "4.6.6",
"@types/lodash.sortby": "4.7.6",
"@types/minimatch": "3.0.3",
"@types/mkdirp": "^1.0.0",
"@types/nock": "10.0.3",
"@types/node": "8.10.56",
"@types/node-fetch": "2.5.4",
Expand Down
1 change: 1 addition & 0 deletions packages/apollo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"listr": "0.14.3",
"lodash.identity": "3.0.0",
"lodash.pickby": "4.6.0",
"mkdirp": "^1.0.3",
"moment": "2.24.0",
"strip-ansi": "5.2.0",
"table": "5.4.6",
Expand Down
16 changes: 10 additions & 6 deletions packages/apollo/src/commands/client/download-schema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { flags } from "@oclif/command";
import { introspectionFromSchema, printSchema } from "graphql";
import { writeFileSync } from "fs";

import { ClientCommand } from "../../Command";
import mkdirp from "mkdirp";
import fs from "fs";
import { dirname as getDirName } from "path";

export default class SchemaDownload extends ClientCommand {
static description =
Expand All @@ -23,8 +23,6 @@ export default class SchemaDownload extends ClientCommand {
];

async run() {
let result;
let gitContext;
await this.runTasks(({ args, project, flags }) => {
const extension = args.output.split(".").pop();
const isSDLFormat = ["graphql", "graphqls", "gql"].includes(extension);
Expand All @@ -36,7 +34,13 @@ export default class SchemaDownload extends ClientCommand {
const formattedSchema = isSDLFormat
? printSchema(schema)
: JSON.stringify(introspectionFromSchema(schema), null, 2);
writeFileSync(args.output, formattedSchema);

try {
await mkdirp(getDirName(args.output));
fs.writeFileSync(args.output, formattedSchema);
} catch (err) {
throw err;
}
}
}
];
Expand Down
12 changes: 7 additions & 5 deletions packages/apollo/src/commands/service/download.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { flags } from "@oclif/command";
import { introspectionFromSchema } from "graphql";
import { writeFileSync } from "fs";
import chalk from "chalk";
import { ProjectCommand } from "../../Command";
import mkdirp from "mkdirp";
import fs from "fs";
import { dirname as getDirName } from "path";

export default class ServiceDownload extends ProjectCommand {
static aliases = ["schema:download"];
Expand All @@ -24,22 +26,22 @@ export default class ServiceDownload extends ProjectCommand {
static args = [
{
name: "output",
description: "Path to write the introspection result to",
description:
"Path to write the introspection result to. Supports .json output only.",
required: true,
default: "schema.json"
}
];

async run() {
let result;
let gitContext;
await this.runTasks(({ args, project, flags }) => [
{
title: `Saving schema to ${args.output}`,
task: async () => {
try {
const schema = await project.resolveSchema({ tag: flags.tag });
writeFileSync(
await mkdirp(getDirName(args.output));
fs.writeFileSync(
args.output,
JSON.stringify(introspectionFromSchema(schema), null, 2)
);
Expand Down