Skip to content

Commit

Permalink
remove feature flag around Rover projects (#215)
Browse files Browse the repository at this point in the history
Co-authored-by: Dylan Anthony <[email protected]>
  • Loading branch information
phryneas and dylan-apollo authored Sep 27, 2024
1 parent 2e56f42 commit 15f0104
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 157 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 57 additions & 7 deletions schemas/apollo.config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,31 @@
"$ref": "#/definitions/baseConfig"
},
{
"type": "object",
"properties": {
"client": {
"$ref": "#/definitions/clientConfig"
"anyOf": [
{
"type": "object",
"properties": {
"client": {
"$ref": "#/definitions/clientConfig"
}
},
"required": [
"client"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"rover": {
"$ref": "#/definitions/roverConfig"
}
},
"required": [
"rover"
],
"additionalProperties": false
}
},
"required": [
"client"
]
}
],
Expand Down Expand Up @@ -146,6 +163,36 @@
"additionalProperties": false,
"description": "Configuration for a Client project."
},
"roverConfig": {
"type": "object",
"properties": {
"bin": {
"type": "string",
"description": "The path to your Rover binary. If omitted, will look in PATH."
},
"profile": {
"type": "string",
"description": "The name of the profile to use."
},
"supergraphConfig": {
"type": [
"string",
"null"
],
"description": "The path to your `supergraph.yaml` file. \nDefaults to a `supergraph.yaml` in the folder of your `apollo.config.json`, if there is one."
},
"extraArgs": {
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Extra arguments to pass to the Rover CLI."
}
},
"additionalProperties": false,
"description": "Configuration for a federated project."
},
"engineConfig": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -173,6 +220,9 @@
"client": {
"description": "Configuration for a Client project."
},
"rover": {
"description": "Configuration for a federated project."
},
"service": {
"description": "This option is no longer supported, please remove it from your configuration file."
}
Expand Down
1 change: 0 additions & 1 deletion src/__e2e__/runTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ async function main() {
const TEST_PORT = 7096;
process.env.APOLLO_ENGINE_ENDPOINT = "http://localhost:7096/apollo";
process.env.MOCK_SERVER_PORT = String(TEST_PORT);
process.env.APOLLO_FEATURE_FLAGS = "rover";
disposables.push(
...(await Promise.all([
runMockServer(TEST_PORT, false, loadDefaultMocks),
Expand Down
4 changes: 2 additions & 2 deletions src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const buildJsonSchemaPlugin = {
const {
configSchema,
clientConfig,
// roverConfig,
roverConfig,
engineConfig,
baseConfig,
// @ts-ignore
Expand All @@ -78,7 +78,7 @@ const buildJsonSchemaPlugin = {
errorMessages: true,
definitions: {
clientConfig,
//roverConfig,
roverConfig,
engineConfig,
baseConfig,
},
Expand Down
75 changes: 28 additions & 47 deletions src/language-server/config/__tests__/loadConfig.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
let { loadConfig } = require("../");
let { ClientConfig, RoverConfig } = require("../config");
import { loadConfig } from "../";
import { ClientConfig, RoverConfig } from "../config";
import * as path from "path";
import * as fs from "fs";

async function withFeatureFlags(flags: string, fn: () => void) {
const FF = process.env.APOLLO_FEATURE_FLAGS;
try {
process.env.APOLLO_FEATURE_FLAGS = flags;
jest.resetModules();
({ loadConfig } = require("../"));
({ ClientConfig, RoverConfig } = require("../config"));
return await fn();
} finally {
process.env.APOLLO_FEATURE_FLAGS = FF;
jest.resetModules();
({ loadConfig } = require("../"));
({ ClientConfig, RoverConfig } = require("../config"));
}
}

const makeNestedDir = (dir: string) => {
if (fs.existsSync(dir)) return;

Expand Down Expand Up @@ -109,25 +93,24 @@ Object {
`);
});

it("loads with rover defaults from different dir", () =>
withFeatureFlags("rover", async () => {
writeFilesToDir(dir, {
"apollo.config.js": `
it("loads with rover defaults from different dir", async () => {
writeFilesToDir(dir, {
"apollo.config.js": `
module.exports = {
rover: {
}
}
`,
});
fs.mkdirSync(`${dir}/bin`);
fs.writeFileSync(`${dir}/bin/rover`, "", { mode: 0o755 });
let oldPath = process.env.PATH;
process.env.PATH = `${dir}/bin:${oldPath}`;
try {
const config = await loadConfig({
configPath: dirPath,
});
fs.mkdirSync(`${dir}/bin`);
fs.writeFileSync(`${dir}/bin/rover`, "", { mode: 0o755 });
let oldPath = process.env.PATH;
process.env.PATH = `${dir}/bin:${oldPath}`;
try {
const config = await loadConfig({
configPath: dirPath,
});
expect(config?.rawConfig).toMatchInlineSnapshot(`
expect(config?.rawConfig).toMatchInlineSnapshot(`
Object {
"engine": Object {
"endpoint": "https://graphql.api.apollographql.com/api/graphql",
Expand All @@ -138,10 +121,10 @@ Object {
},
}
`);
} finally {
process.env.PATH = oldPath;
}
}));
} finally {
process.env.PATH = oldPath;
}
});

it("[deprecated] loads config from package.json", async () => {
writeFilesToDir(dir, {
Expand Down Expand Up @@ -280,7 +263,6 @@ client:

await loadConfig({
configPath: dirPath,
requireConfig: true, // this is what we're testing
});

expect(spy).toHaveBeenCalledWith(
Expand All @@ -299,7 +281,7 @@ client:
}).catch((e: any) => e);

expect(error.message).toMatch(
/Config needs to contain a 'client' field./i,
/Config needs to contain either 'client' or 'rover' fields/i,
);
});
});
Expand Down Expand Up @@ -374,18 +356,17 @@ client:
expect(config).toBeInstanceOf(ClientConfig);
});

it("infers rover projects from config", () =>
withFeatureFlags("rover", async () => {
writeFilesToDir(dir, {
"apollo.config.js": `module.exports = { rover: { bin: "/usr/bin/env" } }`,
});
it("infers rover projects from config", async () => {
writeFilesToDir(dir, {
"apollo.config.js": `module.exports = { rover: { bin: "/usr/bin/env" } }`,
});

const config = await loadConfig({
configPath: dirPath,
});
const config = await loadConfig({
configPath: dirPath,
});

expect(config).toBeInstanceOf(RoverConfig);
}));
expect(config).toBeInstanceOf(RoverConfig);
});
});

describe("service name", () => {
Expand Down
Loading

0 comments on commit 15f0104

Please sign in to comment.