Skip to content

Commit

Permalink
Fix go to definition when a local schema file is provided (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
rylanc authored and James Baxley committed Nov 26, 2018
1 parent aa88d87 commit 7fd1698
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/apollo-language-server/src/schema/providers/file.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// FileSchemaProvider (FileProvider (SDL || IntrospectionResult) => schema)
import { GraphQLSchema, buildClientSchema, Source, buildSchema } from "graphql";
import { readFileSync } from "fs";
import { extname } from "path";
import { extname, resolve } from "path";
import { GraphQLSchemaProvider, SchemaChangeUnsubscribeHandler } from "./base";
import { NotificationHandler } from "vscode-languageserver";

Expand Down Expand Up @@ -39,7 +39,8 @@ export class FileSchemaProvider implements GraphQLSchemaProvider {

this.schema = buildClientSchema({ __schema });
} else if (ext === ".graphql" || ext === ".graphqls" || ext === ".gql") {
this.schema = buildSchema(new Source(result, path));
const uri = `file://${resolve(path)}`;
this.schema = buildSchema(new Source(result, uri));
}
if (!this.schema) throw new Error(`Schema could not be loaded for ${path}`);
return this.schema;
Expand Down

0 comments on commit 7fd1698

Please sign in to comment.