@@ -108,11 +108,11 @@ export class LanguageService {
108108 * @returns {SchemaCacheItem | undefined }
109109 */
110110 public getSchemaForFile ( uri : string ) : SchemaCacheItem | undefined {
111- if ( ! this . _schemas ? .length ) {
111+ if ( ! this . _schemas . length ) {
112112 return ;
113113 }
114114 if ( this . _schemas . length === 1 ) {
115- return this . _schemaCache . get ( this . _schemas [ 0 ] . uri ) ;
115+ return this . _schemaCache . get ( this . _schemas [ 0 ] ! . uri ) ;
116116 }
117117 const schema = this . _schemas . find ( schemaConfig => {
118118 if ( ! schemaConfig . fileMatch ) {
@@ -157,17 +157,15 @@ export class LanguageService {
157157 }
158158
159159 /**
160- * override `schemas` config entirely
161- * @param schema {schemaString}
160+ * Override `schemas` config entirely.
162161 */
163162 public async updateSchemas ( schemas : SchemaConfig [ ] ) : Promise < void > {
164163 this . _schemas = schemas ;
165164 this . _cacheSchemas ( ) ;
166165 }
167166
168167 /**
169- * overwrite an existing schema config by Uri string
170- * @param schema {schemaString}
168+ * Overwrite an existing schema config by Uri string.
171169 */
172170 public updateSchema ( schema : SchemaConfig ) : void {
173171 const schemaIndex = this . _schemas . findIndex ( c => c . uri === schema . uri ) ;
@@ -184,8 +182,7 @@ export class LanguageService {
184182 }
185183
186184 /**
187- * add a schema to the config
188- * @param schema {schemaString}
185+ * Add a schema to the config.
189186 */
190187 public addSchema ( schema : SchemaConfig ) : void {
191188 this . _schemas . push ( schema ) ;
@@ -213,7 +210,7 @@ export class LanguageService {
213210 position : IPosition ,
214211 ) => {
215212 const schema = this . getSchemaForFile ( uri ) ;
216- if ( ! documentText || documentText . length < 1 || ! schema ?. schema ) {
213+ if ( ! documentText || ! schema ?. schema ) {
217214 return [ ] ;
218215 }
219216 return getAutocompleteSuggestions (
@@ -257,7 +254,7 @@ export class LanguageService {
257254 options ?: HoverConfig ,
258255 ) => {
259256 const schema = this . getSchemaForFile ( uri ) ;
260- if ( schema && documentText ? .length > 3 ) {
257+ if ( schema && documentText . length > 3 ) {
261258 return getHoverInformation (
262259 schema . schema ,
263260 documentText ,
@@ -280,9 +277,12 @@ export class LanguageService {
280277 if ( schema && documentText . length > 3 ) {
281278 try {
282279 const documentAST = this . parse ( documentText ) ;
283- const operationFacts = getOperationASTFacts ( documentAST , schema . schema ) ;
284- if ( operationFacts ?. variableToType ) {
285- return getVariablesJSONSchema ( operationFacts . variableToType , {
280+ const { variableToType } = getOperationASTFacts (
281+ documentAST ,
282+ schema . schema ,
283+ ) ;
284+ if ( variableToType ) {
285+ return getVariablesJSONSchema ( variableToType , {
286286 ...options ,
287287 scalarSchemas : schema . customScalarSchemas ,
288288 } ) ;
0 commit comments