|
1 | 1 | import { flags } from "@oclif/command"; |
2 | 2 | import { table } from "heroku-cli-util"; |
3 | | -import { introspectionFromSchema } from "graphql"; |
4 | | - |
| 3 | +import { introspectionFromSchema, printSchema } from "graphql"; |
5 | 4 | import { gitInfo } from "../../git"; |
6 | 5 | import { ProjectCommand } from "../../Command"; |
| 6 | +import { UploadSchemaVariables } from "apollo-language-server/lib/graphqlTypes"; |
7 | 7 |
|
8 | 8 | export default class ServicePush extends ProjectCommand { |
9 | 9 | static aliases = ["schema:publish"]; |
@@ -35,21 +35,30 @@ export default class ServicePush extends ProjectCommand { |
35 | 35 | const schema = await project.resolveSchema({ tag: flags.tag }); |
36 | 36 | gitContext = await gitInfo(this.log); |
37 | 37 |
|
38 | | - const { tag, code } = await project.engine.uploadSchema({ |
| 38 | + const variables: UploadSchemaVariables = { |
39 | 39 | id: config.name, |
40 | 40 | // @ts-ignore |
41 | 41 | // XXX Looks like TS should be generating ReadonlyArrays instead |
42 | 42 | schema: introspectionFromSchema(schema).__schema, |
43 | 43 | tag: flags.tag, |
44 | 44 | gitContext |
45 | | - }); |
46 | | - |
47 | | - result = { |
48 | | - service: config.name, |
49 | | - hash: tag.schema.hash, |
50 | | - tag: tag.tag, |
51 | | - code |
52 | 45 | }; |
| 46 | + |
| 47 | + const response = await project.engine.uploadSchema(variables); |
| 48 | + if (response) { |
| 49 | + result = { |
| 50 | + service: config.name, |
| 51 | + hash: response.tag ? response.tag.schema.hash : null, |
| 52 | + tag: response.tag ? response.tag.tag : null, |
| 53 | + code: response.code |
| 54 | + }; |
| 55 | + } |
| 56 | + |
| 57 | + const { schema: _, ...restVariables } = variables; |
| 58 | + this.debug("Variables sent to Engine:"); |
| 59 | + this.debug(restVariables); |
| 60 | + this.debug("SDL of introspection sent to Engine:"); |
| 61 | + this.debug(printSchema(schema)); |
53 | 62 | } |
54 | 63 | } |
55 | 64 | ]); |
|
0 commit comments