Skip to content

Commit 177f427

Browse files
author
James Baxley
authored
Merge pull request #971 from apollographql/trevor/vscode-package-file-perf
Resolve VS Code + package.json performance concern
2 parents 68332d4 + 96420bd commit 177f427

5 files changed

Lines changed: 11 additions & 24 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ export const loadConfig = async ({
288288
ApolloConfigFormat
289289
>;
290290

291+
if (loadedConfig && loadedConfig.filepath.endsWith("package.json")) {
292+
console.warn(
293+
'The "apollo" package.json configuration key will no longer be supported in Apollo v3. Please use the apollo.config.js file for Apollo project configuration. For more information, see: https://bit.ly/2ByILPj'
294+
);
295+
}
296+
291297
if (requireConfig && !loadedConfig) {
292298
throw new Error(
293299
`No Apollo config found for project. For more information, please refer to:

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {
66
ProposedFeatures,
77
TextDocuments,
88
FileChangeType,
9-
ServerCapabilities,
10-
WorkspaceFolder
9+
ServerCapabilities
1110
} from "vscode-languageserver";
1211
import { QuickPickItem } from "vscode";
1312
import { GraphQLWorkspace } from "./workspace";
@@ -127,11 +126,7 @@ documents.onDidChangeContent(params => {
127126

128127
connection.onDidChangeWatchedFiles(params => {
129128
for (const { uri, type } of params.changes) {
130-
if (
131-
uri.endsWith("apollo.config.js") ||
132-
uri.endsWith("package.json") ||
133-
uri.endsWith(".env")
134-
) {
129+
if (uri.endsWith("apollo.config.js") || uri.endsWith(".env")) {
135130
workspace.reloadProjectForConfig(uri);
136131
}
137132

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,6 @@ export class GraphQLWorkspace {
113113
ignore: "**/node_modules/**"
114114
});
115115

116-
apolloConfigFiles.push(
117-
...fg
118-
.sync("**/package.json", {
119-
cwd: URI.parse(folder.uri).fsPath,
120-
absolute: true,
121-
ignore: "**/node_modules/**"
122-
})
123-
// Every package.json file _potentially_ has an apollo config, but we can filter out
124-
// the ones that don't before we even call loadConfig and send cosmiconfig looking.
125-
.filter(packageFile => {
126-
const { apollo } = require(packageFile);
127-
return Boolean(apollo);
128-
})
129-
);
130-
131116
// only have unique possible folders
132117
const apolloConfigFolders = new Set<string>(apolloConfigFiles.map(dirname));
133118

packages/apollo/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,9 @@ _See code: [src/commands/service/push.ts](https://github.com/apollographql/apoll
458458

459459
# Configuration
460460

461-
The Apollo CLI and VS Code extension can be configured with an Apollo Config file. Apollo configuration is stored as a plain object and can be either specified under the `apollo` key in your `package.json` or as a separate `apollo.config.js` file which exports the config data.
461+
The Apollo CLI and VS Code extension can be configured with an Apollo config file. Apollo configuration is stored as a plain object in an `apollo.config.js` file which exports the configuration. For more information about configuring an Apollo project, see: https://bit.ly/2ByILPj.
462+
463+
> Note: the use of the `apollo` key in the project's package.json file for configuration is deprecated, and will no longer be supported in Apollo v3
462464
463465
You'll need to set up your Apollo configuration for all the features of the Apollo CLI and VS Code extension to work correctly. For full details on how to do that, [visit our docs](https://www.apollographql.com/docs/references/apollo-config.html). A basic configuration (`apollo.config.js` style) looks something like this:
464466

packages/vscode-apollo/src/languageServerClient.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export function getLanguageServerClient(
4949
],
5050
synchronize: {
5151
fileEvents: [
52-
workspace.createFileSystemWatcher("**/package.json"),
5352
workspace.createFileSystemWatcher("**/.env"),
5453
workspace.createFileSystemWatcher("**/*.{graphql,js,ts,jsx,tsx,py}")
5554
]

0 commit comments

Comments
 (0)