@@ -205,15 +205,31 @@ export class MessageProcessor {
205205 }
206206
207207 async _updateGraphQLConfig ( ) {
208- const settings = await this . _connection . workspace . getConfiguration ( {
209- section : 'graphql-config' ,
210- } ) ;
211- const vscodeSettings = await this . _connection . workspace . getConfiguration ( {
212- section : 'vscode-graphql' ,
213- } ) ;
214- if ( settings ?. dotEnvPath ) {
215- require ( 'dotenv' ) . config ( { path : settings . dotEnvPath } ) ;
208+ this . _logger . info ( 'updating config' )
209+ let settings = {
210+ dotEnvPath : null
211+ } ;
212+ let vscodeSettings = { } ;
213+ // try {
214+ // settings = await this.connection.workspace.getConfiguration({
215+ // section: 'graphql-config',
216+ // scopeUri: this._rootPath
217+ // });
218+ // this._logger.info('graphql config loaded')
219+ // vscodeSettings = await this.connection.workspace.getConfiguration({
220+ // section: 'vscode-graphql',
221+ // scopeUri: this._rootPath
222+ // });
223+ // }
224+ // catch(err) {
225+ // this._logger.info(JSON.stringify(err))
226+ // }
227+ this . _logger . info ( 'updating config 1' )
228+
229+ if ( this . _settings ?. dotEnvPath ) {
230+ require ( 'dotenv' ) . config ( { path : settings ?. dotEnvPath } ) ;
216231 }
232+ this . _logger . info ( 'updating config 2' )
217233 this . _settings = { ...settings , ...vscodeSettings } ;
218234 const rootDir = this . _settings ?. load ?. rootDir || this . _rootPath ;
219235 this . _rootPath = rootDir ;
@@ -228,21 +244,28 @@ export class MessageProcessor {
228244 rootDir,
229245 } ;
230246 try {
247+ this . _logger . info ( 'updating config 3' )
231248 // reload the graphql cache
232249 this . _graphQLCache = await getGraphQLCache ( {
233250 parser : this . _parser ,
234251 loadConfigOptions : this . _loadConfigOptions ,
235252
236253 logger : this . _logger ,
237254 } ) ;
255+ this . _logger . info ( 'updating config 4' )
238256 this . _languageService = new GraphQLLanguageService (
239257 this . _graphQLCache ,
240258 this . _logger ,
241259 ) ;
260+ this . _logger . info ( 'updating config 5' )
242261 if ( this . _graphQLConfig || this . _graphQLCache ?. getGraphQLConfig ) {
243262 const config =
244263 this . _graphQLConfig ?? this . _graphQLCache . getGraphQLConfig ( ) ;
264+ this . _logger . info ( 'updating config 6' )
265+ this . _logger . info ( JSON . stringify ( config ) )
245266 await this . _cacheAllProjectFiles ( config ) ;
267+ this . _logger . info ( 'updating config 7' )
268+
246269 }
247270 this . _isInitialized = true ;
248271 } catch ( err ) {
@@ -291,15 +314,18 @@ export class MessageProcessor {
291314 async handleDidOpenOrSaveNotification (
292315 params : DidSaveTextDocumentParams | DidOpenTextDocumentParams ,
293316 ) : Promise < PublishDiagnosticsParams | null > {
317+ this . _logger . info ( 'opening document' )
294318 /**
295319 * Initialize the LSP server when the first file is opened or saved,
296320 * so that we can access the user settings for config rootDir, etc
297321 */
298322 try {
299323 if ( ! this . _isInitialized || ! this . _graphQLCache ) {
324+ this . _logger . info ( 'no cache' )
300325 // don't try to initialize again if we've already tried
301326 // and the graphql config file or package.json entry isn't even there
302327 if ( this . _isGraphQLConfigMissing === true ) {
328+ this . _logger . info ( 'config missing' )
303329 return null ;
304330 }
305331 // then initial call to update graphql config
@@ -308,6 +334,7 @@ export class MessageProcessor {
308334 } catch ( err ) {
309335 this . _logger . error ( String ( err ) ) ;
310336 }
337+ this . _logger . info ( 'opening document 2' )
311338
312339 // Here, we set the workspace settings in memory,
313340 // and re-initialize the language service when a different
@@ -896,10 +923,14 @@ export class MessageProcessor {
896923
897924 async _cacheSchemaText ( uri : string , text : string , version : number ) {
898925 try {
926+ this . _logger . info ( 'cache schema text 1' )
899927 const contents = this . _parser ( text , uri ) ;
900928 if ( contents . length > 0 ) {
901929 await this . _invalidateCache ( { version, uri } , uri , contents ) ;
930+ this . _logger . info ( 'cache schema text 2' )
931+
902932 await this . _updateObjectTypeDefinition ( uri , contents ) ;
933+ this . _logger . info ( 'cache schema text 3' )
903934 }
904935 } catch ( err ) {
905936 this . _logger . error ( String ( err ) ) ;
@@ -909,19 +940,25 @@ export class MessageProcessor {
909940 _uri : UnnormalizedTypeDefPointer ,
910941 project : GraphQLProjectConfig ,
911942 ) {
943+ this . _logger . info ( 'cache schema file 1' )
944+
912945 const uri = _uri . toString ( ) ;
913946
914947 const isFileUri = existsSync ( uri ) ;
915948 let version = 1 ;
916949 if ( isFileUri ) {
917950 const schemaUri = URI . file ( path . join ( project . dirpath , uri ) ) . toString ( ) ;
951+ this . _logger . info ( 'cache schema file 2' )
918952 const schemaDocument = this . _getCachedDocument ( schemaUri ) ;
953+ this . _logger . info ( 'cache schema file 3' )
919954
920955 if ( schemaDocument ) {
921956 version = schemaDocument . version ++ ;
922957 }
923958 const schemaText = readFileSync ( uri , 'utf8' ) ;
959+ this . _logger . info ( 'cache schema file 4' )
924960 await this . _cacheSchemaText ( schemaUri , schemaText , version ) ;
961+ this . _logger . info ( 'cache schema file 5' )
925962 }
926963 }
927964 _getTmpProjectPath (
@@ -952,9 +989,13 @@ export class MessageProcessor {
952989 * @param project
953990 */
954991 async _cacheSchemaPath ( uri : string , project : GraphQLProjectConfig ) {
992+ this . _logger . info ( 'cache schema files 3' )
993+
955994 try {
956995 const files = await glob ( uri ) ;
957996 if ( files && files . length > 0 ) {
997+ this . _logger . info ( 'cache schema files 4' )
998+
958999 await Promise . all (
9591000 files . map ( uriPath => this . _cacheSchemaFile ( uriPath , project ) ) ,
9601001 ) ;
@@ -993,6 +1034,7 @@ export class MessageProcessor {
9931034 }
9941035
9951036 async _cacheSchemaFilesForProject ( project : GraphQLProjectConfig ) {
1037+ this . _logger . info ( 'cache schema files 1' )
9961038 const schema = project ?. schema ;
9971039 const config = project ?. extensions ?. languageService ;
9981040 /**
@@ -1013,9 +1055,13 @@ export class MessageProcessor {
10131055 config ?. cacheSchemaFileForLookup ??
10141056 this ?. _settings ?. cacheSchemaFileForLookup ??
10151057 false ;
1058+ this . _logger . info ( 'cache schema files 2' )
1059+
10161060 if ( cacheSchemaFileForLookup ) {
10171061 await this . _cacheConfigSchema ( project ) ;
10181062 } else if ( typeof schema === 'string' ) {
1063+ this . _logger . info ( 'cache schema files 3' )
1064+
10191065 await this . _cacheSchemaPath ( schema , project ) ;
10201066 } else if ( Array . isArray ( schema ) ) {
10211067 await this . _cacheArraySchema ( schema , project ) ;
@@ -1077,20 +1123,29 @@ export class MessageProcessor {
10771123 */
10781124 async _cacheDocumentFilesforProject ( project : GraphQLProjectConfig ) {
10791125 try {
1126+ this . _logger . info ( 'cacheDocumentFilesforProject 1' )
1127+ this . _logger . info ( JSON . stringify ( project , null , 2 ) )
10801128 const documents = await project . getDocuments ( ) ;
1129+ this . _logger . info ( 'cacheDocumentFilesforProject 2' )
1130+
10811131 return Promise . all (
10821132 documents . map ( async document => {
10831133 if ( ! document . location || ! document . rawSDL ) {
10841134 return ;
10851135 }
1136+ this . _logger . info ( 'cacheDocumentFilesforProject 3' )
1137+
10861138
10871139 let filePath = document . location ;
10881140 if ( ! path . isAbsolute ( filePath ) ) {
10891141 filePath = path . join ( project . dirpath , document . location ) ;
10901142 }
1143+ this . _logger . info ( 'cacheDocumentFilesforProject 4' )
10911144
10921145 // build full system URI path with protocol
10931146 const uri = URI . file ( filePath ) . toString ( ) ;
1147+ this . _logger . info ( 'cacheDocumentFilesforProject 5' )
1148+
10941149
10951150 // I would use the already existing graphql-config AST, but there are a few reasons we can't yet
10961151 const contents = this . _parser ( document . rawSDL , uri ) ;
0 commit comments