Skip to content

Commit 2600b22

Browse files
authored
Fix multiple localSchemaFile bug (#1529)
* change flag typing and parsing
1 parent 5704fc2 commit 2600b22

6 files changed

Lines changed: 13 additions & 10 deletions

File tree

packages/apollo-language-server/src/config/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const DefaultClientConfig = {
108108
export interface ServiceConfigFormat extends ConfigBase {
109109
name?: string;
110110
endpoint?: Exclude<RemoteServiceConfig, "name">;
111-
localSchemaFile?: string;
111+
localSchemaFile?: string | string[];
112112
}
113113

114114
export const DefaultServiceConfig = {

packages/apollo-language-server/src/providers/schema/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ export function schemaProviderFromConfig(
2727
): GraphQLSchemaProvider {
2828
if (isServiceConfig(config)) {
2929
if (config.service.localSchemaFile) {
30-
return new FileSchemaProvider({ path: config.service.localSchemaFile });
30+
const isListOfSchemaFiles = Array.isArray(config.service.localSchemaFile);
31+
return new FileSchemaProvider(
32+
isListOfSchemaFiles
33+
? { paths: config.service.localSchemaFile as string[] }
34+
: { path: config.service.localSchemaFile as string }
35+
);
3136
}
3237

3338
if (config.service.endpoint) {

packages/apollo/src/Command.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,19 @@ export abstract class ProjectCommand extends Command {
169169
}
170170

171171
if (flags.localSchemaFile) {
172+
const files = flags.localSchemaFile.split(",");
172173
if (isClientConfig(config)) {
173174
config.setDefaults({
174175
client: {
175176
service: {
176-
localSchemaFile: flags.localSchemaFile
177+
localSchemaFile: files
177178
}
178179
}
179180
});
180181
} else if (isServiceConfig(config)) {
181182
config.setDefaults({
182183
service: {
183-
localSchemaFile: flags.localSchemaFile
184+
localSchemaFile: files
184185
}
185186
});
186187
}

packages/apollo/src/commands/client/codegen.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ export default class Generate extends ClientCommand {
4141
}),
4242
localSchemaFile: flags.string({
4343
description:
44-
"Path to your local GraphQL schema file (introspection result or SDL)",
45-
multiple: true
44+
"Path to your local GraphQL schema file (introspection result or SDL)"
4645
}),
4746
addTypename: flags.boolean({
4847
description:

packages/apollo/src/commands/service/check.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ export default class ServiceCheck extends ProjectCommand {
287287
}),
288288
localSchemaFile: flags.string({
289289
description:
290-
"Path to your local GraphQL schema file (introspection result or SDL)",
291-
multiple: true
290+
"Path to your local GraphQL schema file (introspection result or SDL)"
292291
}),
293292
markdown: flags.boolean({
294293
description: "Output result in markdown.",

packages/apollo/src/commands/service/push.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ export default class ServicePush extends ProjectCommand {
1919
}),
2020
localSchemaFile: flags.string({
2121
description:
22-
"Path to your local GraphQL schema file (introspection result or SDL)",
23-
multiple: true
22+
"Path to your local GraphQL schema file (introspection result or SDL)"
2423
}),
2524
federated: flags.boolean({
2625
char: "f",

0 commit comments

Comments
 (0)