graphql-tools icon indicating copy to clipboard operation
graphql-tools copied to clipboard

Percent symbol (%) is classified as invalid path

Open ErgEnn opened this issue 1 year ago • 0 comments

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:

CodeSandbox

  1. Make project with graphql query in any code file that would normally be analyzed
  2. Alter the absolute path to have % sign in it at any leaf. (in example app src/invalid%20path/InvalidFile.ts)
  3. 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.

Environment:

  • OS: Windows
  • NodeJS: 20.11.0
  • @graphql-codegen/cli version: 5.0.2

Additional context

Related bugs: https://github.com/ardatan/graphql-tools/issues/4699 https://github.com/dotansimha/graphql-code-generator/issues/7959

ErgEnn avatar Aug 19 '24 09:08 ErgEnn