Skip to content

Commit 11fc68a

Browse files
Temporarily remove run query / webview in VSCode extension (#605)
Remove run query feature for now, to be re-introduced in the future. Revert this commit as a jumping off point for pulling it back in.
1 parent 36a3f2e commit 11fc68a

13 files changed

Lines changed: 143 additions & 3854 deletions

File tree

package-lock.json

Lines changed: 136 additions & 3087 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
"apollo-codegen-typescript": "file:packages/apollo-codegen-typescript",
4141
"apollo-codegen-typescript-legacy": "file:packages/apollo-codegen-typescript-legacy",
4242
"apollo-language-server": "file:packages/apollo-language-server",
43-
"apollo-vscode": "file:packages/apollo-vscode",
44-
"apollo-vscode-webview": "file:packages/apollo-vscode-webview",
45-
"webpack-command": "^0.4.1"
43+
"apollo-vscode": "file:packages/apollo-vscode"
4644
},
4745
"devDependencies": {
4846
"@fancy-test/nock": "^0.1.1",
@@ -64,11 +62,7 @@
6462
"@types/react-dom": "^16.0.7",
6563
"@types/recursive-readdir": "^2.2.0",
6664
"@types/ws": "^6.0.0",
67-
"babel-loader": "^7.1.2",
68-
"babel-preset-react-app": "^3.1.2",
69-
"case-sensitive-paths-webpack-plugin": "2.1.2",
7065
"chai": "^4.1.2",
71-
"css-loader": "1.0.0",
7266
"fs-monkey": "^0.3.3",
7367
"graphql": "^0.13.2",
7468
"husky": "^0.14.3",
@@ -80,17 +74,11 @@
8074
"memfs": "^2.9.4",
8175
"nock": "^9.6.1",
8276
"prettier": "1.14.2",
83-
"style-loader": "0.23.0",
8477
"ts-jest": "^23.1.4",
85-
"ts-loader": "^4.5.0",
8678
"ts-node": "^7.0.1",
87-
"tsconfig-paths-webpack-plugin": "^3.2.0",
8879
"tslib": "^1.9.3",
8980
"typescript": "^3.0.3",
90-
"uglifyjs-webpack-plugin": "^1.3.0",
91-
"url-loader": "1.1.1",
92-
"vsce": "^1.46.0",
93-
"webpack": "4.17.1"
81+
"vsce": "^1.46.0"
9482
},
9583
"jest": {
9684
"projects": [

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

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import {
3030
import {
3131
GraphQLNamedType,
3232
Kind,
33-
visit,
34-
FragmentSpreadNode,
3533
GraphQLField,
3634
GraphQLNonNull,
3735
isAbstractType,
@@ -392,50 +390,11 @@ ${argumentNode.description}
392390

393391
let codeLenses: CodeLens[] = [];
394392

395-
for (const { doc, set } of docsAndSets) {
393+
for (const { doc } of docsAndSets) {
396394
if (!doc.ast) continue;
397395

398396
for (const definition of doc.ast.definitions) {
399-
if (definition.kind === Kind.OPERATION_DEFINITION) {
400-
if (set.endpoint) {
401-
const fragmentSpreads: Set<
402-
graphql.FragmentDefinitionNode
403-
> = new Set();
404-
const searchForReferencedFragments = (node: graphql.ASTNode) => {
405-
visit(node, {
406-
FragmentSpread(node: FragmentSpreadNode) {
407-
const fragDefn = project.fragments[node.name.value];
408-
if (!fragDefn) return;
409-
410-
if (!fragmentSpreads.has(fragDefn)) {
411-
fragmentSpreads.add(fragDefn);
412-
searchForReferencedFragments(fragDefn);
413-
}
414-
}
415-
});
416-
};
417-
418-
searchForReferencedFragments(definition);
419-
420-
codeLenses.push({
421-
range: rangeForASTNode(definition),
422-
command: Command.create(
423-
`Run ${definition.operation}`,
424-
"apollographql.runQuery",
425-
graphql.parse(
426-
[definition, ...fragmentSpreads]
427-
.map(n => graphql.print(n))
428-
.join("\n")
429-
),
430-
definition.operation === "subscription"
431-
? set.endpoint.subscriptions
432-
: set.endpoint.url,
433-
set.endpoint.headers,
434-
graphql.printSchema(set.schema!)
435-
)
436-
});
437-
}
438-
} else if (definition.kind === Kind.FRAGMENT_DEFINITION) {
397+
if (definition.kind === Kind.FRAGMENT_DEFINITION) {
439398
const references = project.fragmentSpreadsForFragment(
440399
definition.name.value
441400
);

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

Lines changed: 3 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1+
import { dirname } from "path";
12
import {
23
createConnection,
34
ProposedFeatures,
45
TextDocuments,
56
FileChangeType,
67
NotificationType
78
} from "vscode-languageserver";
8-
9-
import { GraphQLWorkspace } from "./workspace";
10-
import { GraphQLLanguageProvider } from "./languageProvider";
11-
12-
import { execute, DocumentNode } from "apollo-link";
13-
import { createHttpLink } from "apollo-link-http";
14-
import fetch from "node-fetch";
15-
import { OperationDefinitionNode } from "graphql";
16-
17-
import { WebSocketLink } from "apollo-link-ws";
18-
import { SubscriptionClient } from "subscriptions-transport-ws";
19-
209
import Uri from "vscode-uri";
21-
22-
import * as ws from "ws";
23-
24-
import { dirname } from "path";
2510
import { findAndLoadConfig } from "apollo/lib/config";
11+
import { GraphQLWorkspace } from "./workspace";
12+
import { GraphQLLanguageProvider } from "./languageProvider";
2613

2714
const connection = createConnection(ProposedFeatures.all);
2815

@@ -131,12 +118,6 @@ connection.onInitialize(async params => {
131118
codeLensProvider: {
132119
resolveProvider: false
133120
},
134-
executeCommandProvider: {
135-
commands: [
136-
"apollographql.runQuery",
137-
"apollographql.runQueryWithVariables"
138-
]
139-
},
140121
textDocumentSync: documents.syncKind
141122
}
142123
};
@@ -244,125 +225,4 @@ connection.onCodeLens((params, token) => {
244225
return languageProvider.provideCodeLenses(params.textDocument.uri, token);
245226
});
246227

247-
const createSubscriptionLink = (endpoint: string) => {
248-
const client = new SubscriptionClient(
249-
endpoint,
250-
{
251-
reconnect: true
252-
},
253-
ws
254-
);
255-
256-
return new WebSocketLink(client);
257-
};
258-
259-
const cancellationFunctions: { [id: number]: () => void } = {};
260-
let nextCancellationID = 1;
261-
262-
export const executeAndNotify = (
263-
query: DocumentNode,
264-
endpoint: string,
265-
headers: any,
266-
variables: any
267-
) => {
268-
const operation = query.definitions[0] as OperationDefinitionNode;
269-
const link =
270-
operation.operation === "subscription"
271-
? createSubscriptionLink(endpoint)
272-
: createHttpLink({ uri: endpoint, fetch } as any);
273-
274-
const cancellationID = nextCancellationID;
275-
nextCancellationID++;
276-
277-
const sub = execute(link, {
278-
query,
279-
variables,
280-
context: { headers }
281-
}).subscribe(
282-
value => {
283-
connection.sendNotification(
284-
new NotificationType<any, void>("apollographql/queryResult"),
285-
{ result: value, cancellationID }
286-
);
287-
},
288-
error => {
289-
if (error.result) {
290-
connection.sendNotification(
291-
new NotificationType<any, void>("apollographql/queryResult"),
292-
{ result: error.result, cancellationID }
293-
);
294-
} else {
295-
connection.sendNotification(
296-
new NotificationType<any, void>("apollographql/queryResult"),
297-
{ result: { errors: [error] }, cancellationID }
298-
);
299-
}
300-
}
301-
);
302-
303-
connection.sendNotification(
304-
new NotificationType<any, void>("apollographql/queryResult"),
305-
{ result: "Loading...", cancellationID }
306-
);
307-
308-
cancellationFunctions[cancellationID] = () => {
309-
sub.unsubscribe();
310-
};
311-
};
312-
313-
const operationHasVariables = (operation: OperationDefinitionNode) => {
314-
return (
315-
operation.variableDefinitions && operation.variableDefinitions.length > 0
316-
);
317-
};
318-
319-
connection.onExecuteCommand(params => {
320-
switch (params.command) {
321-
case "apollographql.runQuery":
322-
const operation = (params.arguments![0] as DocumentNode)
323-
.definitions[0] as OperationDefinitionNode;
324-
if (operationHasVariables(operation)) {
325-
connection.sendNotification(
326-
new NotificationType<any, void>("apollographql/requestVariables"),
327-
{
328-
query: params.arguments![0],
329-
endpoint: params.arguments![1],
330-
headers: params.arguments![2],
331-
schema: params.arguments![3],
332-
requestedVariables: operation.variableDefinitions!.map(v => {
333-
return {
334-
name: v.variable.name.value,
335-
typeNode: v.type
336-
};
337-
})
338-
}
339-
);
340-
} else {
341-
executeAndNotify(
342-
params.arguments![0],
343-
params.arguments![1],
344-
params.arguments![2],
345-
{}
346-
);
347-
}
348-
349-
break;
350-
351-
default:
352-
}
353-
});
354-
355-
connection.onNotification(
356-
"apollographql/runQueryWithVariables",
357-
({ query, endpoint, headers, variables }) => {
358-
executeAndNotify(query, endpoint, headers, variables);
359-
}
360-
);
361-
362-
connection.onNotification("apollographql/cancelQuery", ({ cancellationID }) => {
363-
cancellationFunctions[cancellationID]();
364-
delete cancellationFunctions[cancellationID];
365-
});
366-
367-
// Listen on the connection
368228
connection.listen();

packages/apollo-vscode-webview/graphiql.d.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/apollo-vscode-webview/package.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

packages/apollo-vscode-webview/src/App.tsx

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)