graphql-tools
graphql-tools copied to clipboard
Percent symbol (%) is classified as invalid path
Issue workflow progress
Progress of the issue based on the Contributor Workflow
- [X] 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox
- [X] 2. A failing test has been provided
- [X] 3. A local solution has been provided
- [ ] 4. A pull request is pending review
Describe the bug
When there is percent character anywhere in full path to code file (e.g. C:/dev/Repo%20Name/project/src/App.tsx) the codegen fails to analyze that file for graphql queries, since isValidPath classifies that path as invalid.
Such path commonly happens when repository name has whitespaces in it. The resulting git clone url has whitespaces replaced with URL encoded %20 tokens which git clone turns into directory name without URL decoding the repo name.
To Reproduce Steps to reproduce the behavior:
- Make project with graphql query in any code file that would normally be analyzed
- Alter the absolute path to have
%sign in it at any leaf. (in example appsrc/invalid%20path/InvalidFile.ts) - Run codegen and notice that document is not generated for that code file (in example app
src/__generated__/gql.tscontains type definition only for query inValidFile.ts, but notInvalidFile.ts)
Expected behavior
Documents should still be generated when they contain valid character like %.
Alternatively warning could be displayed when such failure occurs.
Environment:
- OS: Windows
- NodeJS: 20.11.0
@graphql-codegen/cliversion: 5.0.2
Additional context
Related bugs: https://github.com/ardatan/graphql-tools/issues/4699 https://github.com/dotansimha/graphql-code-generator/issues/7959