Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit f012a7d

Browse files
alloykastermester
authored andcommitted
[PluginInterface] Add file path to tag finder.
1 parent 7679ee9 commit f012a7d

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/FindGraphQLTags.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,9 @@ function invariant(condition: boolean, msg: string, ...args: any[]) {
181181
}
182182
}
183183

184-
export const find: GraphQLTagFinder = text => {
184+
export const find: GraphQLTagFinder = (text, filePath) => {
185185
const result: GraphQLTag[] = [];
186-
// TODO: Make relay-compiler pass a `File` object instead of just text so e.g. we can get the filename?
187-
const ast = ts.createSourceFile("TODO!", text, ts.ScriptTarget.Latest, true);
186+
const ast = ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true);
188187
visit(ast, tag => result.push(tag));
189188
return result;
190189
};

types/relay-compiler/language/RelayLanguagePluginInterface.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type FormatModule = (
3333
}
3434
) => string;
3535

36-
export type GraphQLTagFinder = (text: string) => Array<GraphQLTag>;
36+
export type GraphQLTagFinder = (text: string, filePath: string) => Array<GraphQLTag>;
3737

3838
export interface TypeGeneratorOptions {
3939
readonly customScalars: { [type: string]: string },

0 commit comments

Comments
 (0)