File tree Expand file tree Collapse file tree
apollo-language-server/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,6 +93,19 @@ function symbolForFieldDefinition(
9393export 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 ,
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff line change @@ -43,4 +43,8 @@ export class GraphQLServiceProject extends GraphQLProject {
4343 }
4444
4545 validate ( ) { }
46+
47+ getProjectStats ( ) {
48+ return { } ;
49+ }
4650}
Original file line number Diff line number Diff 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
216221connection . listen ( ) ;
Original file line number Diff line number Diff line change 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 }
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments