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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- `apollo-graphql`
- <First `apollo-graphql` related entry goes here>
- `apollo-language-server`
- <First `apollo-language-server` related entry goes here>
- Remove error from the case with old and new api keys present [#1893](https://github.com/apollographql/apollo-tooling/pull/1893)
- `apollo-tools`
- <First `apollo-tools` related entry goes here>
- `vscode-apollo`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,22 @@ describe("loadConfig", () => {
);
});

it("Throws when .env defined legacy and new key", async () => {
it("Uses new key when .env defined both legacy and new key", async () => {
writeFilesToDir(dir, {
"my.config.js": `module.exports = { client: { name: 'hello' } }`,
".env.local": `ENGINE_API_KEY=service:yoshi:65489061ko\nAPOLLO_KEY=service:yoshi:65489061ko`
});
const spy = jest.spyOn(Debug, "warning");

const loadConfigPromise = loadConfig({
const config = await loadConfig({
configPath: dirPath,
configFileName: "my.config.js"
});

await expect(loadConfigPromise).rejects.toThrow(/Cannot set both/);
expect(config.engine.apiKey).toEqual("service:yoshi:65489061ko");
expect(spy).toHaveBeenCalledWith(
expect.stringMatching(/Both ENGINE_API_KEY and APOLLO_KEY were found/i)
);
});

// this doesn't work right now :)
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-language-server/src/config/loadConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ export async function loadConfig({
const legacyKey = env[legacyKeyEnvVar];
const key = env[keyEnvVar];
if (legacyKey && key) {
throw new Error(
`Cannot set both ${legacyKeyEnvVar} and ${keyEnvVar}. Please only set ${keyEnvVar}`
Debug.warning(
`Both ${legacyKeyEnvVar} and ${keyEnvVar} were found. ${keyEnvVar} will take precedence.`
);
}
if (legacyKey) {
Expand Down