vscode-apollo 1.20.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +27 -18
- package/.git-blame-ignore-revs +2 -0
- package/.nvmrc +1 -1
- package/.vscode/launch.json +9 -4
- package/.vscode/tasks.json +58 -16
- package/.vscodeignore +12 -1
- package/CHANGELOG.md +78 -0
- package/CODEOWNERS +4 -0
- package/README.md +97 -48
- package/graphql.configuration.json +5 -1
- package/images/marketplace/apollo-wordmark.png +0 -0
- package/jest.config.ts +14 -4
- package/jest.e2e.config.js +17 -0
- package/package.json +67 -68
- package/renovate.json +7 -0
- package/sampleWorkspace/clientSchema/apollo.config.cjs +10 -0
- package/sampleWorkspace/clientSchema/src/clientSchema.js +16 -0
- package/sampleWorkspace/clientSchema/src/test.js +18 -0
- package/sampleWorkspace/fixtures/starwarsSchema.graphql +299 -0
- package/sampleWorkspace/httpSchema/apollo.config.ts +8 -0
- package/sampleWorkspace/httpSchema/src/test.js +9 -0
- package/sampleWorkspace/localSchema/apollo.config.js +8 -0
- package/sampleWorkspace/localSchema/src/test.js +8 -0
- package/sampleWorkspace/localSchemaArray/apollo.config.js +12 -0
- package/sampleWorkspace/localSchemaArray/planets.graphql +20 -0
- package/sampleWorkspace/localSchemaArray/src/test.js +12 -0
- package/sampleWorkspace/sampleWorkspace.code-workspace +20 -0
- package/sampleWorkspace/spotifyGraph/apollo.config.mjs +5 -0
- package/sampleWorkspace/spotifyGraph/src/test.js +11 -0
- package/src/__e2e__/mockServer.js +117 -0
- package/src/__e2e__/mocks.js +13094 -0
- package/src/__e2e__/run.js +23 -0
- package/src/__e2e__/runTests.js +44 -0
- package/src/__e2e__/setup.js +1 -0
- package/src/__e2e__/vscode-environment.js +16 -0
- package/src/__e2e__/vscode.js +1 -0
- package/src/build.js +57 -0
- package/src/env/index.ts +0 -3
- package/src/extension.ts +251 -225
- package/src/language-server/__e2e__/clientSchema.e2e.ts +147 -0
- package/src/language-server/__e2e__/httpSchema.e2e.ts +21 -0
- package/src/language-server/__e2e__/localSchema.e2e.ts +25 -0
- package/src/language-server/__e2e__/localSchemaArray.e2e.ts +31 -0
- package/src/language-server/__e2e__/studioGraph.e2e.ts +65 -0
- package/src/language-server/__e2e__/utils.ts +151 -0
- package/src/language-server/__tests__/diagnostics.test.ts +8 -8
- package/src/language-server/__tests__/fileSet.test.ts +1 -1
- package/src/language-server/__tests__/fixtures/starwarsSchema.ts +2 -2
- package/src/language-server/config/__tests__/config.ts +22 -96
- package/src/language-server/config/__tests__/loadConfig.ts +97 -221
- package/src/language-server/config/__tests__/utils.ts +22 -29
- package/src/language-server/config/config.ts +221 -156
- package/src/language-server/config/loadConfig.ts +26 -153
- package/src/language-server/config/utils.ts +5 -16
- package/src/language-server/diagnostics.ts +17 -8
- package/src/language-server/document.ts +16 -16
- package/src/language-server/engine/index.ts +57 -39
- package/src/language-server/engine/operations/frontendUrlRoot.ts +9 -1
- package/src/language-server/engine/operations/schemaTagsAndFieldStats.ts +9 -1
- package/src/language-server/errors/__tests__/NoMissingClientDirectives.test.ts +10 -5
- package/src/language-server/errors/logger.ts +1 -1
- package/src/language-server/errors/validation.ts +20 -23
- package/src/language-server/fileSet.ts +10 -12
- package/src/language-server/format.ts +1 -1
- package/src/language-server/graphqlTypes.ts +13020 -3455
- package/src/language-server/index.ts +0 -1
- package/src/language-server/languageProvider.ts +29 -32
- package/src/language-server/loadingHandler.ts +10 -27
- package/src/language-server/project/base.ts +32 -25
- package/src/language-server/project/client.ts +80 -114
- package/src/language-server/project/defaultClientSchema.ts +29 -4
- package/src/language-server/providers/schema/__tests__/file.ts +60 -19
- package/src/language-server/providers/schema/base.ts +2 -2
- package/src/language-server/providers/schema/endpoint.ts +15 -34
- package/src/language-server/providers/schema/engine.ts +25 -18
- package/src/language-server/providers/schema/file.ts +41 -32
- package/src/language-server/providers/schema/index.ts +5 -21
- package/src/language-server/server.ts +72 -50
- package/src/language-server/typings/graphql.d.ts +3 -3
- package/src/language-server/utilities/__tests__/graphql.test.ts +42 -54
- package/src/language-server/utilities/debouncer.ts +1 -1
- package/src/language-server/utilities/debug.ts +6 -5
- package/src/language-server/utilities/graphql.ts +17 -16
- package/src/language-server/utilities/source.ts +16 -16
- package/src/language-server/utilities/uri.ts +2 -2
- package/src/language-server/workspace.ts +29 -37
- package/src/languageServerClient.ts +4 -4
- package/src/messages.ts +38 -47
- package/src/tools/__tests__/buildServiceDefinition.test.ts +2 -2
- package/src/tools/buildServiceDefinition.ts +11 -11
- package/src/tools/schema/resolveObject.ts +1 -1
- package/src/tools/utilities/predicates.ts +1 -1
- package/src/utils.ts +7 -6
- package/syntaxes/graphql.dart.json +2 -4
- package/syntaxes/graphql.ex.json +1 -4
- package/tsconfig.build.json +8 -1
- package/tsconfig.json +5 -3
- package/src/env/fetch/fetch.ts +0 -32
- package/src/env/fetch/global.ts +0 -30
- package/src/env/fetch/index.d.ts +0 -2
- package/src/env/fetch/index.ts +0 -2
- package/src/env/fetch/url.ts +0 -9
- package/src/env/polyfills/array.ts +0 -17
- package/src/env/polyfills/index.ts +0 -2
- package/src/env/polyfills/object.ts +0 -7
- package/src/language-server/engine/GraphQLDataSource.ts +0 -124
- package/src/language-server/project/service.ts +0 -48
- package/src/language-server/typings/codemirror.d.ts +0 -4
|
@@ -2,41 +2,36 @@ import {
|
|
|
2
2
|
WorkspaceFolder,
|
|
3
3
|
NotificationHandler,
|
|
4
4
|
PublishDiagnosticsParams,
|
|
5
|
-
} from "vscode-languageserver";
|
|
5
|
+
} from "vscode-languageserver/node";
|
|
6
6
|
import { QuickPickItem } from "vscode";
|
|
7
7
|
import { GraphQLProject, DocumentUri } from "./project/base";
|
|
8
8
|
import { dirname } from "path";
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
loadConfig,
|
|
12
|
-
ApolloConfig,
|
|
13
|
-
isClientConfig,
|
|
14
|
-
ServiceConfig,
|
|
15
|
-
} from "./config";
|
|
9
|
+
import { globSync } from "glob";
|
|
10
|
+
import { loadConfig, ApolloConfig, isClientConfig } from "./config";
|
|
16
11
|
import { LanguageServerLoadingHandler } from "./loadingHandler";
|
|
17
12
|
import { ServiceID, SchemaTag, ClientIdentity } from "./engine";
|
|
18
13
|
import { GraphQLClientProject, isClientProject } from "./project/client";
|
|
19
|
-
import {
|
|
20
|
-
import URI from "vscode-uri";
|
|
14
|
+
import { URI } from "vscode-uri";
|
|
21
15
|
import { Debug } from "./utilities";
|
|
22
|
-
import type { EngineDecoration } from "
|
|
16
|
+
import type { EngineDecoration } from "../messages";
|
|
17
|
+
import { equal } from "@wry/equality";
|
|
23
18
|
|
|
24
19
|
export interface WorkspaceConfig {
|
|
25
|
-
clientIdentity
|
|
20
|
+
clientIdentity: ClientIdentity;
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
export class GraphQLWorkspace {
|
|
29
24
|
private _onDiagnostics?: NotificationHandler<PublishDiagnosticsParams>;
|
|
30
25
|
private _onDecorations?: NotificationHandler<EngineDecoration[]>;
|
|
31
26
|
private _onSchemaTags?: NotificationHandler<[ServiceID, SchemaTag[]]>;
|
|
32
|
-
private _onConfigFilesFound?: NotificationHandler<ApolloConfig[]>;
|
|
27
|
+
private _onConfigFilesFound?: NotificationHandler<(ApolloConfig | Error)[]>;
|
|
33
28
|
private _projectForFileCache: Map<string, GraphQLProject> = new Map();
|
|
34
29
|
|
|
35
30
|
private projectsByFolderUri: Map<string, GraphQLProject[]> = new Map();
|
|
36
31
|
|
|
37
32
|
constructor(
|
|
38
33
|
private LanguageServerLoadingHandler: LanguageServerLoadingHandler,
|
|
39
|
-
private config: WorkspaceConfig
|
|
34
|
+
private config: WorkspaceConfig,
|
|
40
35
|
) {}
|
|
41
36
|
|
|
42
37
|
onDiagnostics(handler: NotificationHandler<PublishDiagnosticsParams>) {
|
|
@@ -51,7 +46,7 @@ export class GraphQLWorkspace {
|
|
|
51
46
|
this._onSchemaTags = handler;
|
|
52
47
|
}
|
|
53
48
|
|
|
54
|
-
onConfigFilesFound(handler: NotificationHandler<ApolloConfig[]>) {
|
|
49
|
+
onConfigFilesFound(handler: NotificationHandler<(ApolloConfig | Error)[]>) {
|
|
55
50
|
this._onConfigFilesFound = handler;
|
|
56
51
|
}
|
|
57
52
|
|
|
@@ -70,12 +65,9 @@ export class GraphQLWorkspace {
|
|
|
70
65
|
configFolderURI: URI.parse(folder.uri),
|
|
71
66
|
clientIdentity,
|
|
72
67
|
})
|
|
73
|
-
:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
configFolderURI: URI.parse(folder.uri),
|
|
77
|
-
clientIdentity,
|
|
78
|
-
});
|
|
68
|
+
: (() => {
|
|
69
|
+
throw new Error("TODO rover project");
|
|
70
|
+
})();
|
|
79
71
|
|
|
80
72
|
project.onDiagnostics((params) => {
|
|
81
73
|
this._onDiagnostics && this._onDiagnostics(params);
|
|
@@ -115,44 +107,42 @@ export class GraphQLWorkspace {
|
|
|
115
107
|
-- ~/:user/server (GraphQLProject) as WorkspaceFolder
|
|
116
108
|
|
|
117
109
|
*/
|
|
118
|
-
const apolloConfigFiles: string[] =
|
|
119
|
-
"**/apollo.config.@(js|ts|cjs)",
|
|
110
|
+
const apolloConfigFiles: string[] = globSync(
|
|
111
|
+
"**/apollo.config.@(js|ts|cjs|mjs)",
|
|
120
112
|
{
|
|
121
113
|
cwd: URI.parse(folder.uri).fsPath,
|
|
122
114
|
absolute: true,
|
|
123
115
|
ignore: "**/node_modules/**",
|
|
124
|
-
}
|
|
116
|
+
},
|
|
125
117
|
);
|
|
126
118
|
|
|
127
119
|
// only have unique possible folders
|
|
128
120
|
const apolloConfigFolders = new Set<string>(apolloConfigFiles.map(dirname));
|
|
129
121
|
|
|
130
122
|
// go from possible folders to known array of configs
|
|
131
|
-
let foundConfigs: ApolloConfig[] = [];
|
|
123
|
+
let foundConfigs: (ApolloConfig | Error)[] = [];
|
|
132
124
|
|
|
133
125
|
const projectConfigs = Array.from(apolloConfigFolders).map((configFolder) =>
|
|
134
|
-
loadConfig({ configPath: configFolder
|
|
126
|
+
loadConfig({ configPath: configFolder })
|
|
135
127
|
.then((config) => {
|
|
136
128
|
if (config) {
|
|
137
129
|
foundConfigs.push(config);
|
|
138
|
-
const
|
|
139
|
-
this.createProject({ config, folder })
|
|
140
|
-
);
|
|
130
|
+
const projectForConfig = this.createProject({ config, folder });
|
|
141
131
|
|
|
142
132
|
const existingProjects =
|
|
143
133
|
this.projectsByFolderUri.get(folder.uri) || [];
|
|
144
134
|
|
|
145
135
|
this.projectsByFolderUri.set(folder.uri, [
|
|
146
136
|
...existingProjects,
|
|
147
|
-
|
|
137
|
+
projectForConfig,
|
|
148
138
|
]);
|
|
149
139
|
} else {
|
|
150
140
|
Debug.error(
|
|
151
|
-
`Workspace failed to load config from: ${configFolder}
|
|
141
|
+
`Workspace failed to load config from: ${configFolder}/`,
|
|
152
142
|
);
|
|
153
143
|
}
|
|
154
144
|
})
|
|
155
|
-
.catch((error) =>
|
|
145
|
+
.catch((error) => foundConfigs.push(error)),
|
|
156
146
|
);
|
|
157
147
|
|
|
158
148
|
await Promise.all(projectConfigs);
|
|
@@ -173,18 +163,17 @@ export class GraphQLWorkspace {
|
|
|
173
163
|
config: project.config,
|
|
174
164
|
folder: { uri } as WorkspaceFolder,
|
|
175
165
|
});
|
|
176
|
-
})
|
|
166
|
+
}),
|
|
177
167
|
);
|
|
178
168
|
});
|
|
179
169
|
}
|
|
180
170
|
|
|
181
171
|
async reloadProjectForConfig(configUri: DocumentUri) {
|
|
182
172
|
const configPath = dirname(URI.parse(configUri).fsPath);
|
|
183
|
-
|
|
184
173
|
let config: ApolloConfig | null;
|
|
185
174
|
let error;
|
|
186
175
|
try {
|
|
187
|
-
config = await loadConfig({ configPath
|
|
176
|
+
config = await loadConfig({ configPath });
|
|
188
177
|
} catch (e: any) {
|
|
189
178
|
config = null;
|
|
190
179
|
error = e;
|
|
@@ -192,11 +181,14 @@ export class GraphQLWorkspace {
|
|
|
192
181
|
|
|
193
182
|
const project = this.projectForFile(configUri);
|
|
194
183
|
|
|
195
|
-
if (
|
|
196
|
-
this._onConfigFilesFound(error);
|
|
184
|
+
if (this._onConfigFilesFound) {
|
|
185
|
+
this._onConfigFilesFound([config || error]);
|
|
197
186
|
}
|
|
198
187
|
// If project exists, update the config
|
|
199
188
|
if (project && config) {
|
|
189
|
+
if (equal(project.config.rawConfig, config.rawConfig)) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
200
192
|
await Promise.all(project.updateConfig(config));
|
|
201
193
|
this.reloadService();
|
|
202
194
|
}
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
LanguageClientOptions,
|
|
5
5
|
LanguageClient,
|
|
6
6
|
RevealOutputChannelOn,
|
|
7
|
-
} from "vscode-languageclient";
|
|
7
|
+
} from "vscode-languageclient/node";
|
|
8
8
|
import { workspace, OutputChannel } from "vscode";
|
|
9
9
|
|
|
10
10
|
const { version, referenceID } = require("../package.json");
|
|
11
11
|
|
|
12
12
|
export function getLanguageServerClient(
|
|
13
13
|
serverModule: string,
|
|
14
|
-
outputChannel: OutputChannel
|
|
14
|
+
outputChannel: OutputChannel,
|
|
15
15
|
) {
|
|
16
16
|
const env = {
|
|
17
17
|
APOLLO_CLIENT_NAME: "Apollo VS Code",
|
|
@@ -59,7 +59,7 @@ export function getLanguageServerClient(
|
|
|
59
59
|
fileEvents: [
|
|
60
60
|
workspace.createFileSystemWatcher("**/.env?(.local)"),
|
|
61
61
|
workspace.createFileSystemWatcher(
|
|
62
|
-
"**/*.{graphql,js,ts,jsx,tsx,vue,svelte,py,rb,dart,re,ex,exs}"
|
|
62
|
+
"**/*.{graphql,js,ts,cjs,mjs,jsx,tsx,vue,svelte,py,rb,dart,re,ex,exs}",
|
|
63
63
|
),
|
|
64
64
|
],
|
|
65
65
|
},
|
|
@@ -75,6 +75,6 @@ export function getLanguageServerClient(
|
|
|
75
75
|
"apollographql",
|
|
76
76
|
"Apollo GraphQL",
|
|
77
77
|
serverOptions,
|
|
78
|
-
clientOptions
|
|
78
|
+
clientOptions,
|
|
79
79
|
);
|
|
80
80
|
}
|
package/src/messages.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
NotificationHandler,
|
|
5
|
-
NotificationHandler0,
|
|
6
|
-
NotificationType,
|
|
7
|
-
NotificationType0,
|
|
8
|
-
Range,
|
|
9
|
-
} from "vscode-languageclient";
|
|
10
|
-
import type { IConnection as GenericConnection } from "vscode-languageserver";
|
|
1
|
+
import { QuickPickItem } from "vscode";
|
|
2
|
+
import { NotificationType, RequestType } from "vscode-jsonrpc";
|
|
3
|
+
import { Range } from "vscode-languageclient/node";
|
|
11
4
|
|
|
12
5
|
export interface TypeStats {
|
|
13
6
|
service?: number;
|
|
@@ -40,45 +33,43 @@ export type EngineDecoration =
|
|
|
40
33
|
hoverMessage: string;
|
|
41
34
|
};
|
|
42
35
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"apollographql/loadingComplete": number;
|
|
48
|
-
"apollographql/loading": { message: string; token: number };
|
|
49
|
-
"apollographql/engineDecorations": { decorations: EngineDecoration[] };
|
|
50
|
-
serverDebugMessage: {
|
|
51
|
-
type: "info" | "warning" | "error" | "errorTelemetry";
|
|
52
|
-
message: string;
|
|
53
|
-
};
|
|
36
|
+
export const LanguageServerRequests = {
|
|
37
|
+
FileStats: new RequestType<{ uri: string }, ProjectStats, unknown>(
|
|
38
|
+
"apollographql/fileStats",
|
|
39
|
+
),
|
|
54
40
|
};
|
|
55
41
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// Allow other notification types
|
|
64
|
-
onNotification<RO>(
|
|
65
|
-
type: NotificationType0<RO>,
|
|
66
|
-
handler: NotificationHandler0
|
|
67
|
-
): void;
|
|
68
|
-
onNotification<P, RO>(
|
|
69
|
-
type: NotificationType<P, RO>,
|
|
70
|
-
handler: NotificationHandler<P>
|
|
71
|
-
): void;
|
|
42
|
+
/**
|
|
43
|
+
* Notifications sent to the language server
|
|
44
|
+
*/
|
|
45
|
+
export const LanguageServerCommands = {
|
|
46
|
+
GetStats: new NotificationType<{ uri: string }>("apollographql/getStats"),
|
|
47
|
+
ReloadService: new NotificationType<void>("apollographql/reloadService"),
|
|
48
|
+
TagSelected: new NotificationType<QuickPickItem>("apollographql/tagSelected"),
|
|
72
49
|
};
|
|
73
50
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Notifications sent from the language server
|
|
53
|
+
*/
|
|
54
|
+
export const LanguageServerNotifications = {
|
|
55
|
+
StatsLoaded: new NotificationType<ProjectStats>("apollographql/statsLoaded"),
|
|
56
|
+
ConfigFilesFound: new NotificationType<string>(
|
|
57
|
+
"apollographql/configFilesFound",
|
|
58
|
+
),
|
|
59
|
+
TagsLoaded: new NotificationType<string>("apollographql/tagsLoaded"),
|
|
60
|
+
LoadingComplete: new NotificationType<number>(
|
|
61
|
+
"apollographql/loadingComplete",
|
|
62
|
+
),
|
|
63
|
+
Loading: new NotificationType<{
|
|
64
|
+
message: string;
|
|
65
|
+
token: number;
|
|
66
|
+
}>("apollographql/loading"),
|
|
67
|
+
EngineDecorations: new NotificationType<{
|
|
68
|
+
decorations: EngineDecoration[];
|
|
69
|
+
}>("apollographql/engineDecorations"),
|
|
70
|
+
ServerDebugMessage: new NotificationType<{
|
|
71
|
+
type: "info" | "warning" | "error" | "errorTelemetry";
|
|
72
|
+
message: string;
|
|
73
|
+
stack?: string;
|
|
74
|
+
}>("serverDebugMessage"),
|
|
84
75
|
};
|
|
@@ -169,11 +169,11 @@ Array [
|
|
|
169
169
|
const schema = service.schema!;
|
|
170
170
|
|
|
171
171
|
expect(schema.getDirective("something")).toMatchInlineSnapshot(
|
|
172
|
-
`"@something"
|
|
172
|
+
`"@something"`,
|
|
173
173
|
);
|
|
174
174
|
|
|
175
175
|
expect(schema.getDirective("another")).toMatchInlineSnapshot(
|
|
176
|
-
`"@another"
|
|
176
|
+
`"@another"`,
|
|
177
177
|
);
|
|
178
178
|
});
|
|
179
179
|
|
|
@@ -30,7 +30,7 @@ interface GraphQLServiceDefinition {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function buildServiceDefinition(
|
|
33
|
-
modules: GraphQLSchemaModule[]
|
|
33
|
+
modules: GraphQLSchemaModule[],
|
|
34
34
|
): GraphQLServiceDefinition {
|
|
35
35
|
const errors: GraphQLError[] = [];
|
|
36
36
|
|
|
@@ -87,14 +87,14 @@ export function buildServiceDefinition(
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
for (const [typeName, typeDefinitions] of Object.entries(
|
|
90
|
-
typeDefinitionsMap
|
|
90
|
+
typeDefinitionsMap,
|
|
91
91
|
)) {
|
|
92
92
|
if (typeDefinitions.length > 1) {
|
|
93
93
|
errors.push(
|
|
94
94
|
new GraphQLError(
|
|
95
95
|
`Type "${typeName}" was defined more than once.`,
|
|
96
|
-
typeDefinitions
|
|
97
|
-
)
|
|
96
|
+
typeDefinitions,
|
|
97
|
+
),
|
|
98
98
|
);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -104,8 +104,8 @@ export function buildServiceDefinition(
|
|
|
104
104
|
errors.push(
|
|
105
105
|
new GraphQLError(
|
|
106
106
|
`Directive "${directiveName}" was defined more than once.`,
|
|
107
|
-
directives
|
|
108
|
-
)
|
|
107
|
+
directives,
|
|
108
|
+
),
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -131,13 +131,13 @@ export function buildServiceDefinition(
|
|
|
131
131
|
if (operationTypeMap[operation]) {
|
|
132
132
|
throw new GraphQLError(
|
|
133
133
|
`Must provide only one ${operation} type in schema.`,
|
|
134
|
-
[schemaDefinition]
|
|
134
|
+
[schemaDefinition],
|
|
135
135
|
);
|
|
136
136
|
}
|
|
137
137
|
if (!(typeDefinitionsMap[typeName] || typeExtensionsMap[typeName])) {
|
|
138
138
|
throw new GraphQLError(
|
|
139
139
|
`Specified ${operation} type "${typeName}" not found in document.`,
|
|
140
|
-
[schemaDefinition]
|
|
140
|
+
[schemaDefinition],
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
143
|
operationTypeMap[operation] = typeName;
|
|
@@ -166,8 +166,8 @@ export function buildServiceDefinition(
|
|
|
166
166
|
errors.push(
|
|
167
167
|
new GraphQLError(
|
|
168
168
|
`Cannot extend type "${typeName}" because it does not exist in the existing schema.`,
|
|
169
|
-
typeExtensions
|
|
170
|
-
)
|
|
169
|
+
typeExtensions,
|
|
170
|
+
),
|
|
171
171
|
);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -209,7 +209,7 @@ export function buildServiceDefinition(
|
|
|
209
209
|
|
|
210
210
|
function addResolversToSchema(
|
|
211
211
|
schema: GraphQLSchema,
|
|
212
|
-
resolvers: GraphQLResolverMap<unknown
|
|
212
|
+
resolvers: GraphQLResolverMap<unknown>,
|
|
213
213
|
) {
|
|
214
214
|
for (const [typeName, fieldConfigs] of Object.entries(resolvers)) {
|
|
215
215
|
const type = schema.getType(typeName);
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { LanguageClient } from "vscode-languageclient/node";
|
|
2
|
+
import type { ProjectStats } from "./messages";
|
|
2
3
|
|
|
3
4
|
export const timeSince = (date: number) => {
|
|
4
5
|
const seconds = Math.floor((+new Date() - date) / 1000);
|
|
@@ -17,7 +18,7 @@ export const timeSince = (date: number) => {
|
|
|
17
18
|
|
|
18
19
|
export const printNoFileOpenMessage = (
|
|
19
20
|
client: LanguageClient,
|
|
20
|
-
extVersion: string
|
|
21
|
+
extVersion: string,
|
|
21
22
|
) => {
|
|
22
23
|
client.outputChannel.appendLine("------------------------------");
|
|
23
24
|
client.outputChannel.appendLine(`🚀 Apollo GraphQL v${extVersion}`);
|
|
@@ -27,7 +28,7 @@ export const printNoFileOpenMessage = (
|
|
|
27
28
|
export const printStatsToClientOutputChannel = (
|
|
28
29
|
client: LanguageClient,
|
|
29
30
|
stats: ProjectStats,
|
|
30
|
-
extVersion: string
|
|
31
|
+
extVersion: string,
|
|
31
32
|
) => {
|
|
32
33
|
client.outputChannel.appendLine("------------------------------");
|
|
33
34
|
client.outputChannel.appendLine(`🚀 Apollo GraphQL v${extVersion}`);
|
|
@@ -37,7 +38,7 @@ export const printStatsToClientOutputChannel = (
|
|
|
37
38
|
client.outputChannel.appendLine(
|
|
38
39
|
"❌ Service stats could not be loaded. This may be because you're missing an apollo.config.js file " +
|
|
39
40
|
"or it is misconfigured. For more information about configuring Apollo projects, " +
|
|
40
|
-
"see the guide here (https://go.apollo.dev/t/config)."
|
|
41
|
+
"see the guide here (https://go.apollo.dev/t/config).",
|
|
41
42
|
);
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
@@ -54,12 +55,12 @@ export const printStatsToClientOutputChannel = (
|
|
|
54
55
|
client.outputChannel.appendLine(
|
|
55
56
|
`📈 Number of Types: ${stats.types.total} (${
|
|
56
57
|
stats.types.client
|
|
57
|
-
} client ${stats.types.client === 1 ? "type" : "types"})
|
|
58
|
+
} client ${stats.types.client === 1 ? "type" : "types"})`,
|
|
58
59
|
);
|
|
59
60
|
|
|
60
61
|
if (stats.lastFetch && timeSince(stats.lastFetch)) {
|
|
61
62
|
client.outputChannel.appendLine(
|
|
62
|
-
`🗓 Last Fetched ${timeSince(stats.lastFetch)} Ago
|
|
63
|
+
`🗓 Last Fetched ${timeSince(stats.lastFetch)} Ago`,
|
|
63
64
|
);
|
|
64
65
|
}
|
|
65
66
|
client.outputChannel.appendLine("------------------------------");
|
package/syntaxes/graphql.ex.json
CHANGED
package/tsconfig.build.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"rootDir": "./src",
|
|
4
4
|
"outDir": "./lib",
|
|
5
|
-
"target": "
|
|
5
|
+
"target": "es2020",
|
|
6
6
|
"module": "commonjs",
|
|
7
7
|
"moduleResolution": "node",
|
|
8
8
|
"esModuleInterop": true,
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"declaration": true,
|
|
11
11
|
"declarationMap": true,
|
|
12
12
|
"removeComments": true,
|
|
13
|
+
"allowJs": true,
|
|
13
14
|
"strict": true,
|
|
14
15
|
"noImplicitAny": true,
|
|
15
16
|
"noImplicitReturns": true,
|
|
@@ -17,9 +18,10 @@
|
|
|
17
18
|
"noUnusedParameters": false,
|
|
18
19
|
"noUnusedLocals": false,
|
|
19
20
|
"forceConsistentCasingInFileNames": true,
|
|
20
|
-
"lib": ["
|
|
21
|
+
"lib": ["es2020", "esnext.asynciterable"],
|
|
21
22
|
"types": ["node", "jest"],
|
|
22
23
|
"baseUrl": "."
|
|
23
24
|
},
|
|
24
|
-
"
|
|
25
|
+
"include": ["./src"],
|
|
26
|
+
"exclude": ["./lib", "jest.config.ts", "./sampleWorkspace"]
|
|
25
27
|
}
|
package/src/env/fetch/fetch.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Agent as HttpAgent } from "http";
|
|
2
|
-
import { Agent as HttpsAgent } from "https";
|
|
3
|
-
|
|
4
|
-
export type RequestAgent = HttpAgent | HttpsAgent;
|
|
5
|
-
|
|
6
|
-
export type ReferrerPolicy =
|
|
7
|
-
| ""
|
|
8
|
-
| "no-referrer"
|
|
9
|
-
| "no-referrer-when-downgrade"
|
|
10
|
-
| "same-origin"
|
|
11
|
-
| "origin"
|
|
12
|
-
| "strict-origin"
|
|
13
|
-
| "origin-when-cross-origin"
|
|
14
|
-
| "strict-origin-when-cross-origin"
|
|
15
|
-
| "unsafe-url";
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
default as fetch,
|
|
19
|
-
Request,
|
|
20
|
-
Response,
|
|
21
|
-
Headers,
|
|
22
|
-
ResponseInit,
|
|
23
|
-
BodyInit,
|
|
24
|
-
RequestInfo,
|
|
25
|
-
HeadersInit,
|
|
26
|
-
Body,
|
|
27
|
-
RequestInit,
|
|
28
|
-
RequestMode,
|
|
29
|
-
RequestCredentials,
|
|
30
|
-
RequestCache,
|
|
31
|
-
RequestRedirect,
|
|
32
|
-
} from "node-fetch";
|
package/src/env/fetch/global.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
declare function fetch(
|
|
2
|
-
input?: RequestInfo,
|
|
3
|
-
init?: RequestInit
|
|
4
|
-
): Promise<Response>;
|
|
5
|
-
|
|
6
|
-
declare interface GlobalFetch {
|
|
7
|
-
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
declare interface WindowOrWorkerGlobalScope {
|
|
11
|
-
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type RequestInfo = import("./fetch").RequestInfo;
|
|
15
|
-
type Headers = import("./fetch").Headers;
|
|
16
|
-
type HeadersInit = import("./fetch").HeadersInit;
|
|
17
|
-
type Body = import("./fetch").Body;
|
|
18
|
-
type Request = import("./fetch").Request;
|
|
19
|
-
type RequestAgent = import("./fetch").RequestAgent;
|
|
20
|
-
type RequestInit = import("./fetch").RequestInit;
|
|
21
|
-
type RequestMode = import("./fetch").RequestMode;
|
|
22
|
-
type RequestCredentials = import("./fetch").RequestCredentials;
|
|
23
|
-
type RequestCache = import("./fetch").RequestCache;
|
|
24
|
-
type RequestRedirect = import("./fetch").RequestRedirect;
|
|
25
|
-
type ReferrerPolicy = import("./fetch").ReferrerPolicy;
|
|
26
|
-
type Response = import("./fetch").Response;
|
|
27
|
-
type ResponseInit = import("./fetch").ResponseInit;
|
|
28
|
-
type BodyInit = import("./fetch").BodyInit;
|
|
29
|
-
type URLSearchParams = import("./url").URLSearchParams;
|
|
30
|
-
type URLSearchParamsInit = import("./url").URLSearchParamsInit;
|
package/src/env/fetch/index.d.ts
DELETED
package/src/env/fetch/index.ts
DELETED
package/src/env/fetch/url.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { URLSearchParams } from "url";
|
|
2
|
-
export { URL, URLSearchParams } from "url";
|
|
3
|
-
|
|
4
|
-
export type URLSearchParamsInit =
|
|
5
|
-
| URLSearchParams
|
|
6
|
-
| string
|
|
7
|
-
| { [key: string]: Object | Object[] | undefined }
|
|
8
|
-
| Iterable<[string, Object]>
|
|
9
|
-
| Array<[string, Object]>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference lib="esnext.array" />
|
|
2
|
-
import "core-js/features/array/flat";
|
|
3
|
-
import "core-js/features/array/flat-map";
|
|
4
|
-
|
|
5
|
-
// The built-in Array.flat typings don't contain an overload for ReadonlyArray<U>[],
|
|
6
|
-
// which means the return type is inferred to be any[] instead of U[], hence this augmentation.
|
|
7
|
-
declare global {
|
|
8
|
-
interface Array<T> {
|
|
9
|
-
/**
|
|
10
|
-
* Returns a new array with all sub-array elements concatenated into it recursively up to the
|
|
11
|
-
* specified depth.
|
|
12
|
-
*
|
|
13
|
-
* @param depth The maximum recursion depth
|
|
14
|
-
*/
|
|
15
|
-
flat<U>(this: ReadonlyArray<U>[], depth?: 1): U[];
|
|
16
|
-
}
|
|
17
|
-
}
|