diff --git a/.vscode/launch.json b/.vscode/launch.json index 0a57c17056..c6d70f04e3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -52,5 +52,11 @@ "port": 9002, "sourceMaps": true } + ], + "compounds": [ + { + "name": "Extension + Server", + "configurations": ["Launch VS Code Extension", "Attach to TS Server"] + } ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 1483758400..bb606d6b4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## Upcoming - +- `apollo` + - Fix configuration loading and schema tag support [#925](https://github.com/apollographql/apollo-tooling/pull/925) ## `apollo@2.3.1` diff --git a/apollo.config.js b/apollo.config.js index 7f3d63d554..0df86dd621 100644 --- a/apollo.config.js +++ b/apollo.config.js @@ -1,7 +1,7 @@ module.exports = { client: { name: "Apollo CLI", - service: "engine-api-prod", + service: "engine@master", includes: ["./packages/apollo-language-server/**/*.ts"] }, engine: { diff --git a/packages/apollo-language-server/src/config.ts b/packages/apollo-language-server/src/config.ts index 78ccd5d079..34437be294 100644 --- a/packages/apollo-language-server/src/config.ts +++ b/packages/apollo-language-server/src/config.ts @@ -303,7 +303,7 @@ export const loadConfig = async ({ } } - const resolvedName = name || nameFromKey; + let resolvedName = name || nameFromKey; // The CLI passes in a type when loading config. The editor extension // does not. So we determine the type of the config here, and use it if @@ -311,8 +311,19 @@ export const loadConfig = async ({ let resolvedType: "client" | "service"; if (type) { resolvedType = type; + if ( + loadedConfig && + loadedConfig.config.client && + typeof loadedConfig.config.client.service === "string" + ) { + resolvedName = loadedConfig.config.client.service; + } } else if (loadedConfig && loadedConfig.config.client) { resolvedType = "client"; + resolvedName = + typeof loadedConfig.config.client.service === "string" + ? loadedConfig.config.client.service + : resolvedName; } else if (loadedConfig && loadedConfig.config.service) { resolvedType = "service"; } else { diff --git a/packages/apollo-language-server/src/workspace.ts b/packages/apollo-language-server/src/workspace.ts index 533a72fef5..dba9f2fcd1 100644 --- a/packages/apollo-language-server/src/workspace.ts +++ b/packages/apollo-language-server/src/workspace.ts @@ -103,11 +103,18 @@ export class GraphQLWorkspace { }); apolloConfigFiles.push( - ...fg.sync("**/package.json", { - cwd: URI.parse(folder.uri).fsPath, - absolute: true, - ignore: "**/node_modules/**" - }) + ...fg + .sync("**/package.json", { + cwd: URI.parse(folder.uri).fsPath, + absolute: true, + ignore: "**/node_modules/**" + }) + // Every package.json file _potentially_ has an apollo config, but we can filter out + // the ones that don't before we even call loadConfig and send cosmiconfig looking. + .filter(packageFile => { + const { apollo } = require(packageFile); + return Boolean(apollo); + }) ); // only have unique possible folders diff --git a/packages/apollo/src/Command.ts b/packages/apollo/src/Command.ts index 1559ab307b..c69b062294 100644 --- a/packages/apollo/src/Command.ts +++ b/packages/apollo/src/Command.ts @@ -126,7 +126,7 @@ export abstract class ProjectCommand extends Command { type: this.type }); - if (flags.tag) config.tag = flags.tag; + config.tag = flags.tag || config.tag || "current"; // flag overides config.setDefaults({ engine: { diff --git a/packages/apollo/src/commands/client/check.ts b/packages/apollo/src/commands/client/check.ts index 92b2d3354e..76bb76fc82 100644 --- a/packages/apollo/src/commands/client/check.ts +++ b/packages/apollo/src/commands/client/check.ts @@ -12,8 +12,7 @@ export default class ClientCheck extends ClientCommand { ...ClientCommand.flags, tag: flags.string({ char: "t", - description: "The published tag to check this client against", - default: "current" + description: "The published tag to check this client against" }) }; @@ -35,7 +34,7 @@ export default class ClientCheck extends ClientCommand { const { changes } = await project.engine.checkOperations({ id: config.name, operations: ctx.operations, - tag: flags.tag, + tag: config.tag, gitContext: ctx.gitContext });