Skip to content

Commit 63e048f

Browse files
author
Dimitri POSTOLOV
authored
fix(file-loader): location path must be normalized (#3121)
1 parent 4f3e2f5 commit 63e048f

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

.changeset/eighty-books-develop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-tools/graphql-file-loader': patch
3+
---
4+
5+
fix(file-loader): location path must be normalized

packages/load/tests/loaders/schema/schema-from-typedefs.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe('schema from typedefs', () => {
152152
expect(schemaWithSources.extensions['sources']).toBeDefined();
153153
expect(schemaWithSources.extensions['sources']).toHaveLength(1);
154154
expect(schemaWithSources.extensions['sources'][0]).toMatchObject(expect.objectContaining({
155-
name: glob
155+
name: glob.replace('.', process.cwd())
156156
}))
157157

158158
const schemaWithoutSources = await load(glob, {

packages/loaders/graphql-file/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ export class GraphQLFileLoader implements UniversalLoader<GraphQLFileLoaderOptio
127127
const normalizedFilePath = isAbsolute(pointer) ? pointer : resolve(options.cwd || processCwd(), pointer);
128128
const rawSDL: string = await readFile(normalizedFilePath, { encoding: 'utf8' });
129129

130-
return this.handleFileContent(rawSDL, pointer, options);
130+
return this.handleFileContent(rawSDL, normalizedFilePath, options);
131131
}
132132

133133
loadSync(pointer: SchemaPointerSingle | DocumentPointerSingle, options: GraphQLFileLoaderOptions): Source {
134134
const normalizedFilePath = isAbsolute(pointer) ? pointer : resolve(options.cwd || processCwd(), pointer);
135135
const rawSDL = readFileSync(normalizedFilePath, { encoding: 'utf8' });
136-
return this.handleFileContent(rawSDL, pointer, options);
136+
return this.handleFileContent(rawSDL, normalizedFilePath, options);
137137
}
138138

139139
handleFileContent(rawSDL: string, pointer: string, options: GraphQLFileLoaderOptions) {

0 commit comments

Comments
 (0)