11import { extname } from "path" ;
22import { readFileSync } from "fs" ;
3- import Uri from "vscode-uri" ;
3+ import URI from "vscode-uri" ;
44
55import {
66 TypeSystemDefinitionNode ,
@@ -48,6 +48,22 @@ export interface GraphQLProjectConfig {
4848 fileSet : FileSet ;
4949 loadingHandler : LoadingHandler ;
5050}
51+
52+ export interface TypeStats {
53+ service ?: number ;
54+ client ?: number ;
55+ total ?: number ;
56+ }
57+
58+ export interface ProjectStats {
59+ type : string ;
60+ loaded : boolean ;
61+ serviceId ?: string ;
62+ types ?: TypeStats ;
63+ tag ?: string ;
64+ lastFetch ?: number ;
65+ }
66+
5167export abstract class GraphQLProject implements GraphQLSchemaProvider {
5268 public schemaProvider : GraphQLSchemaProvider ;
5369 protected _onDiagnostics ?: NotificationHandler < PublishDiagnosticsParams > ;
@@ -65,6 +81,8 @@ export abstract class GraphQLProject implements GraphQLSchemaProvider {
6581 private fileSet : FileSet ;
6682 protected loadingHandler : LoadingHandler ;
6783
84+ protected lastLoadDate ?: number ;
85+
6886 constructor ( {
6987 config,
7088 fileSet,
@@ -106,6 +124,8 @@ export abstract class GraphQLProject implements GraphQLSchemaProvider {
106124
107125 protected abstract initialize ( ) : Promise < void > [ ] ;
108126
127+ abstract getProjectStats ( ) : ProjectStats ;
128+
109129 get isReady ( ) : boolean {
110130 return this . _isReady ;
111131 }
@@ -124,10 +144,12 @@ export abstract class GraphQLProject implements GraphQLSchemaProvider {
124144 }
125145
126146 public resolveSchema ( config : SchemaResolveConfig ) : Promise < GraphQLSchema > {
147+ this . lastLoadDate = + new Date ( ) ;
127148 return this . schemaProvider . resolveSchema ( config ) ;
128149 }
129150
130151 public onSchemaChange ( handler : NotificationHandler < GraphQLSchema > ) {
152+ this . lastLoadDate = + new Date ( ) ;
131153 return this . schemaProvider . onSchemaChange ( handler ) ;
132154 }
133155
@@ -136,15 +158,15 @@ export abstract class GraphQLProject implements GraphQLSchemaProvider {
136158 }
137159
138160 includesFile ( uri : DocumentUri ) {
139- return this . fileSet . includesFile ( Uri . parse ( uri ) . fsPath ) ;
161+ return this . fileSet . includesFile ( URI . parse ( uri ) . fsPath ) ;
140162 }
141163
142164 async scanAllIncludedFiles ( ) {
143165 await this . loadingHandler . handle (
144166 `Loading queries for ${ this . displayName } ` ,
145167 ( async ( ) => {
146168 for ( const filePath of this . fileSet . allFiles ( ) ) {
147- const uri = Uri . file ( filePath ) . toString ( ) ;
169+ const uri = URI . file ( filePath ) . toString ( ) ;
148170
149171 // If we already have query documents for this file, that means it was either
150172 // opened or changed before we got a chance to read it.
@@ -157,7 +179,7 @@ export abstract class GraphQLProject implements GraphQLSchemaProvider {
157179 }
158180
159181 fileDidChange ( uri : DocumentUri ) {
160- const filePath = Uri . parse ( uri ) . fsPath ;
182+ const filePath = URI . parse ( uri ) . fsPath ;
161183 const extension = extname ( filePath ) ;
162184 const languageId = fileAssociations [ extension ] ;
163185
0 commit comments