-
Notifications
You must be signed in to change notification settings - Fork 97

Description
Issue workflow progress
Progress of the issue based on the Contributor Workflow
- 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox
Make sure to fork this template and run
yarn generate
in the terminal.Please make sure the Codegen and plugins version under
package.json
matches yours. - 2. A failing test has been provided
- 3. A local solution has been provided
- 4. A pull request is pending review
Describe the bug
I am attempting to write a graphql config that will auto-generate typescript code based on embedded gql templates in .ts files.
I have found a bug that is caused by .d.ts
(typescript type definitions files) also being included in the documents glob.
To Reproduce
Steps to reproduce the behavior:
Use a configuration that includes .ts files. In this example, a .d.ts file may exist in src/global.d.ts
.
---
projects:
jellybean:
schema: schema.graphql
documents:
- src/**/*.jellybean.{graphql,gql}
- src/**/*.tsx
- src/**/*.ts
extensions:
codegen:
generates:
generated-api.ts:
plugins:
- typescript
- typescript-operations
- typescript-react-query
This config errors with:
Could not parse the TypeScript file at src/global.d.ts to extract the graphql tags
SyntaxError: Unexpected token (3:28)
Things I have tried:
- Adding a documents entry:
"!(**/*.d.ts)"
- Adding the negation in the document rule itself:
src/**/!(.d)*.ts
- Adding an exclude entry under jellybean, e.g.
exclude: "**/*.d.ts"
- Adding an absolute path to the file that needs to be excluded. e.g.
exclude: 'src/global.d.ts'
All of these have had no effect and .d.ts files are always included. I can only fix it by removing the src/**/*.ts
entry.
Expected behavior
.d.ts
files should be excluded and everything should work like magic.
Environment:
- OS: macOS 12.5.1 (x86_64)
- GraphQL Config Version: 4.3.5 (via
@graphql-codegen/[email protected]
) - NodeJS: v18.8.0
Additional context