ardatan / graphql-tools

:wrench: Utility library for GraphQL to build, stitch and mock GraphQL schemas in the SDL-first approach
https://www.graphql-tools.com
MIT License
5.35k stars 814 forks source link

Percent symbol (%) is classified as invalid path #6454

Open ErgEnn opened 2 months ago

ErgEnn commented 2 months ago

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, 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:

Additional context

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