Skip to content

Commit cb27455

Browse files
committed
wip
1 parent e626a8b commit cb27455

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export abstract class GraphQLProject implements GraphQLSchemaProvider {
6565
private fileSet: FileSet;
6666
protected loadingHandler: LoadingHandler;
6767

68+
protected lastLoadDate?: number;
69+
6870
constructor({
6971
config,
7072
fileSet,
@@ -126,10 +128,12 @@ export abstract class GraphQLProject implements GraphQLSchemaProvider {
126128
}
127129

128130
public resolveSchema(config: SchemaResolveConfig): Promise<GraphQLSchema> {
131+
this.lastLoadDate = +new Date();
129132
return this.schemaProvider.resolveSchema(config);
130133
}
131134

132135
public onSchemaChange(handler: NotificationHandler<GraphQLSchema>) {
136+
this.lastLoadDate = +new Date();
133137
return this.schemaProvider.onSchemaChange(handler);
134138
}
135139

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

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

8787
private fieldStats?: FieldStats;
88-
private lastLoadDate?: number;
88+
protected lastLoadDate?: number;
8989

9090
constructor({
9191
config,

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ export class GraphQLServiceProject extends GraphQLProject {
4545
validate() {}
4646

4747
getProjectStats() {
48-
return {};
48+
// use this to remove primitives and internal fields for stats
49+
const filterTypes = (type: string) =>
50+
!/__.*|Boolean|ID|Int|String|Float/.test(type);
51+
52+
const serviceTypes = this.schema
53+
? Object.keys(this.schema.getTypeMap()).filter(filterTypes).length
54+
: 0;
55+
56+
return {
57+
loaded: true,
58+
serviceId: this.displayName(),
59+
types: {
60+
service: serviceTypes,
61+
client: 0,
62+
total: serviceTypes
63+
},
64+
tag: this.config.tag,
65+
lastFetch: this.lastLoadDate
66+
};
4967
}
5068
}

0 commit comments

Comments
 (0)