[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.
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 app src/invalid%20path/InvalidFile.ts)
Run codegen and notice that document is not generated for that code file (in example app src/__generated__/gql.ts contains type definition only for query in ValidFile.ts, but not InvalidFile.ts)
Expected behavior
Documents should still be generated when they contain valid character like %.
Alternatively warning could be displayed when such failure occurs.
Issue workflow progress
Progress of the issue based on the Contributor Workflow
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, sinceisValidPath
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:
CodeSandbox
%
sign in it at any leaf. (in example appsrc/invalid%20path/InvalidFile.ts
)src/__generated__/gql.ts
contains 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:
@graphql-codegen/cli
version: 5.0.2Additional context
Related bugs: https://github.com/ardatan/graphql-tools/issues/4699 https://github.com/dotansimha/graphql-code-generator/issues/7959