Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove schema cache invalidation #3631

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spotty-cameras-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'graphql-language-service-server': patch
---

Fix schema cache invalidation for network schemas
22 changes: 0 additions & 22 deletions packages/graphql-language-service-server/src/MessageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,6 @@ export class MessageProcessor {
await this._invalidateCache({ uri, version }, uri, contents);
await this._updateFragmentDefinition(uri, contents);
await this._updateObjectTypeDefinition(uri, contents, project);
await this._updateSchemaIfChanged(project, uri);
return { contents, version };
} catch {
return { contents: [], version: 0 };
Expand Down Expand Up @@ -1301,27 +1300,6 @@ export class MessageProcessor {
}
}

private async _updateSchemaIfChanged(
project: GraphQLProjectConfig,
uri: Uri,
): Promise<void> {
await Promise.all(
unwrapProjectSchema(project).map(async schema => {
const schemaFilePath = path.resolve(project.dirpath, schema);
const uriFilePath = URI.parse(uri).fsPath;
if (uriFilePath === schemaFilePath) {
try {
const file = await readFile(schemaFilePath, 'utf-8');
// only invalidate the schema cache if we can actually parse the file
// otherwise, leave the last valid one in place
parse(file, { noLocation: true });
this._graphQLCache.invalidateSchemaCacheForProject(project);
} catch {}
}
}),
);
}

private async _updateObjectTypeDefinition(
uri: Uri,
contents: CachedContent[],
Expand Down
Loading