Skip to content

Commit

Permalink
feat: allow ampersand in file names to load (#4603)
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Jul 27, 2022
1 parent fa93a77 commit 2a3b45e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .changeset/tender-forks-yawn.md
@@ -0,0 +1,8 @@
---
'@graphql-tools/graphql-file-loader': minor
'@graphql-tools/utils': minor
---

Allow `&` in filenames.

Related to https://github.com/dotansimha/graphql-code-generator/issues/6174
1 change: 1 addition & 0 deletions packages/loaders/graphql-file/tests/loader.spec.ts
Expand Up @@ -19,6 +19,7 @@ describe('GraphQLFileLoader', () => {
})(canLoad => {
it('should return true for a valid pointer', async () => {
await expect(canLoad(getPointer('type-defs.graphql'), {})).resolves.toBe(true);
await expect(canLoad(getPointer('typedefs-&-copy.graphql'), {})).resolves.toBe(true);
});

it('should return true for a valid absolute path', async () => {
Expand Down
@@ -0,0 +1,7 @@
#import AFragment from "./fragment.graphql"

query MyQuery {
a {
...AFragment
}
}
2 changes: 1 addition & 1 deletion packages/utils/src/helpers.ts
Expand Up @@ -25,7 +25,7 @@ export function isDocumentString(str: any): boolean {
return false;
}

const invalidPathRegex = /[‘“!%&^<=>`]/;
const invalidPathRegex = /[‘“!%^<=>`]/;
export function isValidPath(str: any): boolean {
return typeof str === 'string' && !invalidPathRegex.test(str);
}
Expand Down

0 comments on commit 2a3b45e

Please sign in to comment.