Skip to content

Commit 34dea45

Browse files
committed
wip
1 parent c0ac805 commit 34dea45

8 files changed

Lines changed: 56 additions & 4 deletions

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ function symbolForFieldDefinition(
9393
export class GraphQLLanguageProvider {
9494
constructor(public workspace: GraphQLWorkspace) {}
9595

96+
async provideStatus() {
97+
if (
98+
this.workspace &&
99+
this.workspace.projects &&
100+
this.workspace.projects.length
101+
)
102+
return this.workspace.projects[0].getProjectStats();
103+
104+
return {
105+
loaded: false
106+
};
107+
}
108+
96109
async provideCompletionItems(
97110
uri: DocumentUri,
98111
position: Position,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ export abstract class GraphQLProject implements GraphQLSchemaProvider {
106106

107107
protected abstract initialize(): Promise<void>[];
108108

109+
abstract getProjectStats(): any;
110+
109111
get isReady(): boolean {
110112
return this._isReady;
111113
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export class GraphQLClientProject extends GraphQLProject {
8585
private _onSchemaTags?: NotificationHandler<[ServiceID, SchemaTag[]]>;
8686

8787
private fieldStats?: FieldStats;
88+
private lastLoadDate?: number;
8889

8990
constructor({
9091
config,
@@ -113,6 +114,18 @@ export class GraphQLClientProject extends GraphQLProject {
113114
return [this.scanAllIncludedFiles(), this.loadServiceSchema()];
114115
}
115116

117+
public getProjectStats() {
118+
return {
119+
serviceId: this.serviceID,
120+
types: this.serviceSchema
121+
? Object.keys(this.serviceSchema.getTypeMap).length
122+
: 0,
123+
tag: this.config.tag,
124+
loaded: this.serviceID,
125+
lastFetch: ""
126+
};
127+
}
128+
116129
onDecorations(handler: (any: any) => void) {
117130
this._onDecorations = handler;
118131
}
@@ -216,6 +229,9 @@ export class GraphQLClientProject extends GraphQLProject {
216229
this._onSchemaTags && this._onSchemaTags([serviceID, schemaTags]);
217230
this.fieldStats = fieldStats;
218231

232+
console.log(this.fieldStats);
233+
this.lastLoadDate = +new Date();
234+
219235
this.generateDecorations();
220236
})()
221237
);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ export class GraphQLServiceProject extends GraphQLProject {
4343
}
4444

4545
validate() {}
46+
47+
getProjectStats() {
48+
return {};
49+
}
4650
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,10 @@ connection.onNotification(
212212
(selection: QuickPickItem) => workspace.updateSchemaTag(selection)
213213
);
214214

215+
connection.onNotification("apollographql/getStatus", () => {
216+
const status = languageProvider.provideStatus();
217+
connection.sendNotification("apollographql/statusLoaded", status);
218+
});
219+
215220
// Listen on the connection
216221
connection.listen();

packages/vscode-apollo/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@
111111
"command": "apollographql/reloadService",
112112
"title": "Reload schema",
113113
"category": "Apollo"
114+
},
115+
{
116+
"command": "apollographql/showStatus",
117+
"title": "Show Status",
118+
"category": "Apollo"
114119
}
115120
]
116121
}

packages/vscode-apollo/src/extension.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ export function activate(context: ExtensionContext) {
4242
run: {
4343
module: serverModule,
4444
transport: TransportKind.ipc,
45-
options: {
46-
env
47-
}
45+
options: debugOptions
4846
},
4947
debug: {
5048
module: serverModule,
@@ -86,6 +84,15 @@ export function activate(context: ExtensionContext) {
8684
context.subscriptions.push(client.start());
8785

8886
client.onReady().then(() => {
87+
commands.registerCommand("apollographql/showStatus", () => {
88+
client.sendNotification("apollographql/getStatus");
89+
});
90+
91+
client.onNotification("apollographql/statusLoaded", params => {
92+
client.outputChannel.appendLine("Hello");
93+
client.outputChannel.show();
94+
});
95+
8996
commands.registerCommand("apollographql/reloadService", () => {
9097
// wipe out tags when reloading
9198
// XXX we should clean up this handling

packages/vscode-apollo/src/statusBar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class ApolloStatusBar {
1616
this.statusBarItem.text = "Apollo GraphQL $(rss)";
1717
this.statusBarItem.show();
1818

19-
// this.statusBarItem.command = "apollographql/showOutputChannel";
19+
this.statusBarItem.command = "apollographql/showStatus";
2020
// context.subscriptions.push(this.statusBarItem);
2121
}
2222

0 commit comments

Comments
 (0)