Skip to content

Commit 7fd1698

Browse files
rylancJames Baxley
authored andcommitted
Fix go to definition when a local schema file is provided (#727)
1 parent aa88d87 commit 7fd1698

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • packages/apollo-language-server/src/schema/providers

packages/apollo-language-server/src/schema/providers/file.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// FileSchemaProvider (FileProvider (SDL || IntrospectionResult) => schema)
22
import { GraphQLSchema, buildClientSchema, Source, buildSchema } from "graphql";
33
import { readFileSync } from "fs";
4-
import { extname } from "path";
4+
import { extname, resolve } from "path";
55
import { GraphQLSchemaProvider, SchemaChangeUnsubscribeHandler } from "./base";
66
import { NotificationHandler } from "vscode-languageserver";
77

@@ -39,7 +39,8 @@ export class FileSchemaProvider implements GraphQLSchemaProvider {
3939

4040
this.schema = buildClientSchema({ __schema });
4141
} else if (ext === ".graphql" || ext === ".graphqls" || ext === ".gql") {
42-
this.schema = buildSchema(new Source(result, path));
42+
const uri = `file://${resolve(path)}`;
43+
this.schema = buildSchema(new Source(result, uri));
4344
}
4445
if (!this.schema) throw new Error(`Schema could not be loaded for ${path}`);
4546
return this.schema;

0 commit comments

Comments
 (0)