graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

graphql-codegen unable to process paths with # (pound sign)

Open isaiahtaylorhh opened this issue 6 years ago • 8 comments

Describe the bug When pointing to a schema in codegen.yml that has a pound sign in the path, graphql-codegen --config codegen.yml fails with:

Unable to find any GraphQL type definitions for the following pointers: 
    
          - #test/schema.graphql

To Reproduce Steps to reproduce the behavior:

  1. My GraphQL schema:
any schema
  1. My GraphQL operations:
any operations
  1. My codegen.yml config file:
overwrite: true
schema: "#test/schema.graphql"
generates:
  src/generated/graphql.ts:
    plugins:
      - "typescript"

Expected behavior I expected it to find the file and generate the types. Instead, it fails as described above. If you remove the pound sign from both the folder and the .yml, it works as expected. Escaping did not help.

Environment:

  • OS: Mac
  • NodeJS: 13.3.0

package.json:

{
"devDependencies": {
    "@graphql-codegen/cli": "^1.12.1",
    "@graphql-codegen/typescript": "1.12.1",
    "graphql": "^14.6.0",
}

Additional context

This is a problem for people trying to use this with AWS Amplify. They name their folder where the schema is generated #current-cloud-backend.

isaiahtaylorhh avatar Feb 05 '20 18:02 isaiahtaylorhh

same looks like for directories starting with a plus sign.

Uter1007 avatar Feb 10 '20 14:02 Uter1007

@isaiahtaylor We are working on it. Can please try the following in the meantime?

schema: "./#test/schema.graphql"

dotansimha avatar Feb 10 '20 14:02 dotansimha

I would need the plus sign as valid char. I think the current problem relies on the ValidPath Method => https://github.com/ardatan/graphql-toolkit/blob/5071524af2d74318085c8f6c1390f96421da1f75/packages/common/src/helpers.ts#L53

It will not load any of these special signs.

Uter1007 avatar Feb 10 '20 15:02 Uter1007

Is it possible to escape it in the next release ? Maybe instead of restricting special chars maybe we could just add "\" before it (or other techniques). This would be awesome. Cheers.

Uter1007 avatar Feb 10 '20 15:02 Uter1007

We can try, we tried a regex that would fit Windows users, but it breaks for Mac/Linux users, because + and # are valid there. @ardatan Can you please take a look? I think maybe just simplifying the Regex should work.

dotansimha avatar Feb 10 '20 15:02 dotansimha

@dotansimha It's fixed in graphql-toolkit https://github.com/ardatan/graphql-toolkit/commit/a8b136580d13ef933950c5a7515e735f158efb28

ardatan avatar Mar 17 '20 09:03 ardatan

@ardatan can you please release new toolkit? or maybe with @kamilkisiela 's new changes?

dotansimha avatar Mar 17 '20 10:03 dotansimha

Fixed in v1.13.1 🎉

dotansimha avatar Mar 17 '20 16:03 dotansimha