Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
28 changes: 26 additions & 2 deletions packages/apollo/src/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,19 @@ export interface ProjectContext<Flags = any, Args = any> {
args: Args;
}

export interface Flags {
Comment thread
trevor-scheer marked this conversation as resolved.
config?: string;
header?: string[];
endpoint?: string;
localSchemaFile?: string;
key?: string;
engine?: string;
frontend?: string;
tag?: string;
}

const headersArrayToObject = (
arr: string[]
arr?: string[]
): Record<string, string> | undefined => {
if (!arr) return;
return arr
Expand Down Expand Up @@ -96,7 +107,7 @@ export abstract class ProjectCommand extends Command {
});
}

protected async createConfig(flags: any) {
protected async createConfig(flags: Flags) {
let service;
if (process.env.ENGINE_API_KEY)
service = getServiceFromKey(process.env.ENGINE_API_KEY);
Expand Down Expand Up @@ -128,6 +139,19 @@ export abstract class ProjectCommand extends Command {
});
}

if (flags.localSchemaFile) {
Comment thread
trevor-scheer marked this conversation as resolved.
config.setDefaults({
client: {
service: {
localSchemaFile: flags.localSchemaFile
}
},
service: {
localSchemaFile: flags.localSchemaFile
}
});
}

// load per command type defaults;
if (this.configMap) {
const defaults = this.configMap(flags);
Expand Down
3 changes: 3 additions & 0 deletions packages/apollo/src/commands/client/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export default class Generate extends ClientCommand {
"Type of code generator to use (swift | typescript | flow | scala), inferred from output",
required: true
}),
localSchemaFile: flags.string({
description: "Path to your local GraphQL schema file"
Comment thread
trevor-scheer marked this conversation as resolved.
Outdated
}),
addTypename: flags.boolean({
description: "Automatically add __typename to your queries",
default: true
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo/src/commands/client/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const engineSignature = (_TODO_operationAST: DocumentNode): string => {
return engineDefaultSignature(_TODO_operationAST, "TODO");
};

export default class ServicePush extends ClientCommand {
static description = "Push a service to Engine";
export default class ClientExtract extends ClientCommand {
static description = "Extract queries from a client";
static flags = {
...ClientCommand.flags
};
Expand Down
6 changes: 5 additions & 1 deletion packages/apollo/src/commands/service/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ export default class ServicePush extends ProjectCommand {
...ProjectCommand.flags,
tag: flags.string({
char: "t",
description: "The published tag to check this service against",
description: "The tag to publish this service to",
default: "current"
}),
localSchemaFile: flags.string({
description: "Path to your local GraphQL schema file"
})
};

Expand All @@ -27,6 +30,7 @@ export default class ServicePush extends ProjectCommand {
if (!config.name) {
throw new Error("No service found to link to Engine");
}

const schema = await project.resolveSchema({ tag: flags.tag });
gitContext = await gitInfo();

Expand Down