Skip to content

Commit

Permalink
fix: fix Windows fileUri to resolve type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Cellule authored and acao committed Mar 8, 2022
1 parent 64826c8 commit ab83198
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-roses-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'graphql-language-service-server': patch
---

Fixed Windows fileUri when resolving type definition location
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export class GraphQLCache implements GraphQLCacheInterface {
// the docs indicate that is what's there :shrug:
const cacheEntry = globResult.statCache[filePath] as fs.Stats;
return {
filePath: URI.parse(filePath).toString(),
filePath: URI.file(filePath).toString(),
mtime: Math.trunc(cacheEntry.mtime.getTime() / 1000),
size: cacheEntry.size,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class MessageProcessor {
};
this._tmpDir = tmpDir || tmpdir();
this._tmpDirBase = path.join(this._tmpDir, 'graphql-language-service');
this._tmpUriBase = URI.parse(this._tmpDirBase).toString();
this._tmpUriBase = URI.file(this._tmpDirBase).toString();
this._loadConfigOptions = loadConfigOptions;
if (
loadConfigOptions.extensions &&
Expand Down Expand Up @@ -833,7 +833,7 @@ export class MessageProcessor {
const isFileUri = existsSync(uri);
let version = 1;
if (isFileUri) {
const schemaUri = URI.parse(path.join(project.dirpath, uri)).toString();
const schemaUri = URI.file(path.join(project.dirpath, uri)).toString();
const schemaDocument = this._getCachedDocument(schemaUri);

if (schemaDocument) {
Expand All @@ -859,7 +859,7 @@ export class MessageProcessor {
projectTmpPath = path.join(projectTmpPath, appendPath);
}
if (prependWithProtocol) {
return URI.parse(path.resolve(projectTmpPath)).toString();
return URI.file(path.resolve(projectTmpPath)).toString();
} else {
return path.resolve(projectTmpPath);
}
Expand Down Expand Up @@ -1014,7 +1014,7 @@ export class MessageProcessor {
}

// build full system URI path with protocol
const uri = URI.parse(filePath).toString();
const uri = URI.file(filePath).toString();

// i would use the already existing graphql-config AST, but there are a few reasons we can't yet
const contents = this._parser(document.rawSDL, uri);
Expand Down

2 comments on commit ab83198

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.