@@ -108,11 +108,11 @@ export class LanguageService {
108
108
* @returns {SchemaCacheItem | undefined }
109
109
*/
110
110
public getSchemaForFile ( uri : string ) : SchemaCacheItem | undefined {
111
- if ( ! this . _schemas ? .length ) {
111
+ if ( ! this . _schemas . length ) {
112
112
return ;
113
113
}
114
114
if ( this . _schemas . length === 1 ) {
115
- return this . _schemaCache . get ( this . _schemas [ 0 ] . uri ) ;
115
+ return this . _schemaCache . get ( this . _schemas [ 0 ] ! . uri ) ;
116
116
}
117
117
const schema = this . _schemas . find ( schemaConfig => {
118
118
if ( ! schemaConfig . fileMatch ) {
@@ -157,17 +157,15 @@ export class LanguageService {
157
157
}
158
158
159
159
/**
160
- * override `schemas` config entirely
161
- * @param schema {schemaString}
160
+ * Override `schemas` config entirely.
162
161
*/
163
162
public async updateSchemas ( schemas : SchemaConfig [ ] ) : Promise < void > {
164
163
this . _schemas = schemas ;
165
164
this . _cacheSchemas ( ) ;
166
165
}
167
166
168
167
/**
169
- * overwrite an existing schema config by Uri string
170
- * @param schema {schemaString}
168
+ * Overwrite an existing schema config by Uri string.
171
169
*/
172
170
public updateSchema ( schema : SchemaConfig ) : void {
173
171
const schemaIndex = this . _schemas . findIndex ( c => c . uri === schema . uri ) ;
@@ -184,8 +182,7 @@ export class LanguageService {
184
182
}
185
183
186
184
/**
187
- * add a schema to the config
188
- * @param schema {schemaString}
185
+ * Add a schema to the config.
189
186
*/
190
187
public addSchema ( schema : SchemaConfig ) : void {
191
188
this . _schemas . push ( schema ) ;
@@ -213,7 +210,7 @@ export class LanguageService {
213
210
position : IPosition ,
214
211
) => {
215
212
const schema = this . getSchemaForFile ( uri ) ;
216
- if ( ! documentText || documentText . length < 1 || ! schema ?. schema ) {
213
+ if ( ! documentText || ! schema ?. schema ) {
217
214
return [ ] ;
218
215
}
219
216
return getAutocompleteSuggestions (
@@ -257,7 +254,7 @@ export class LanguageService {
257
254
options ?: HoverConfig ,
258
255
) => {
259
256
const schema = this . getSchemaForFile ( uri ) ;
260
- if ( schema && documentText ? .length > 3 ) {
257
+ if ( schema && documentText . length > 3 ) {
261
258
return getHoverInformation (
262
259
schema . schema ,
263
260
documentText ,
@@ -280,9 +277,12 @@ export class LanguageService {
280
277
if ( schema && documentText . length > 3 ) {
281
278
try {
282
279
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 , {
286
286
...options ,
287
287
scalarSchemas : schema . customScalarSchemas ,
288
288
} ) ;
0 commit comments