Skip to content

Commit

Permalink
fix: useSchemaFileDefinitions, cleanup (#1674)
Browse files Browse the repository at this point in the history
  • Loading branch information
acao committed Sep 23, 2020
1 parent f0226dd commit 3673455
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/graphql-language-service-server/src/MessageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,8 @@ export class MessageProcessor {
params: DidChangeWatchedFilesParams,
): Promise<Array<PublishDiagnosticsParams | undefined> | null> {
if (!this._isInitialized || !this._graphQLCache) {
console.log('not yet initialized');
return null;
}
console.log({ params });

return Promise.all(
params.changes.map(async (change: FileEvent) => {
Expand All @@ -569,7 +567,7 @@ export class MessageProcessor {
v => change.uri.match(v)?.length,
)
) {
console.log('updating graphql config');
this._logger.info('updating graphql config');
this._updateGraphQLConfig();
}

Expand Down Expand Up @@ -668,11 +666,17 @@ export class MessageProcessor {
position.line -= parentRange.start.line;
}

const result = await this._languageService.getDefinition(
query,
position,
textDocument.uri,
);
let result = null;

try {
result = await this._languageService.getDefinition(
query,
position,
textDocument.uri,
);
} catch (err) {
// these thrown errors end up getting fired before the service is initialized, so lets cool down on that
}

const inlineFragments: string[] = [];

Expand Down Expand Up @@ -793,7 +797,6 @@ export class MessageProcessor {
documents.map(async ([uri]) => {
const cachedDocument = this._getCachedDocument(uri);
if (!cachedDocument) {
console.error('A cached document cannot be found.');
return [];
}
const docSymbols = await this._languageService.getDocumentSymbols(
Expand Down Expand Up @@ -880,10 +883,9 @@ export class MessageProcessor {
* The default temporary schema file seems preferrable until we have graphql source maps
*/
const useSchemaFileDefinitions =
config?.useSchemaFileDefinitions ??
this?._settings?.useSchemaFileDefinitions ??
(config?.useSchemaFileDefinitions ??
this?._settings?.useSchemaFileDefinitions) ||
false;
console.log({ useSchemaFileDefinitions });
if (!useSchemaFileDefinitions) {
await this._cacheConfigSchema(project);
} else {
Expand Down

0 comments on commit 3673455

Please sign in to comment.