Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix configuration loading and schema tag support #925

Merged
merged 5 commits into from
Jan 25, 2019
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
6 changes: 6 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@
"port": 9002,
"sourceMaps": true
}
],
"compounds": [
{
"name": "Extension + Server",
"configurations": ["Launch VS Code Extension", "Attach to TS Server"]
}
]
}
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Upcoming

<!-- add changes for upcoming versions here -->
- `apollo`
- Fix configuration loading and schema tag support [#925](https://github.com/apollographql/apollo-tooling/pull/925)

## `[email protected]`

Expand Down
2 changes: 1 addition & 1 deletion apollo.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
client: {
name: "Apollo CLI",
service: "engine-api-prod",
service: "engine@master",
includes: ["./packages/apollo-language-server/**/*.ts"]
},
engine: {
Expand Down
13 changes: 12 additions & 1 deletion packages/apollo-language-server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,27 @@ 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
// the type wasn't explicitly passed in.
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 {
Expand Down
17 changes: 12 additions & 5 deletions packages/apollo-language-server/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo/src/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
5 changes: 2 additions & 3 deletions packages/apollo/src/commands/client/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
})
};

Expand All @@ -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
});

Expand Down