File tree Expand file tree Collapse file tree
packages/apollo-language-server/src/project Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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,
Original file line number Diff line number Diff 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+ ! / _ _ .* | B o o l e a n | I D | I n t | S t r i n g | F l o a t / . 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}
You can’t perform that action at this time.
0 commit comments