Skip to content

Commit

Permalink
fix(file-loader): location path must be normalized (ardatan#3121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri POSTOLOV authored Jul 1, 2021
1 parent 4f3e2f5 commit 63e048f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-books-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/graphql-file-loader': patch
---

fix(file-loader): location path must be normalized
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('schema from typedefs', () => {
expect(schemaWithSources.extensions['sources']).toBeDefined();
expect(schemaWithSources.extensions['sources']).toHaveLength(1);
expect(schemaWithSources.extensions['sources'][0]).toMatchObject(expect.objectContaining({
name: glob
name: glob.replace('.', process.cwd())
}))

const schemaWithoutSources = await load(glob, {
Expand Down
4 changes: 2 additions & 2 deletions packages/loaders/graphql-file/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ export class GraphQLFileLoader implements UniversalLoader<GraphQLFileLoaderOptio
const normalizedFilePath = isAbsolute(pointer) ? pointer : resolve(options.cwd || processCwd(), pointer);
const rawSDL: string = await readFile(normalizedFilePath, { encoding: 'utf8' });

return this.handleFileContent(rawSDL, pointer, options);
return this.handleFileContent(rawSDL, normalizedFilePath, options);
}

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

handleFileContent(rawSDL: string, pointer: string, options: GraphQLFileLoaderOptions) {
Expand Down

0 comments on commit 63e048f

Please sign in to comment.