Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client:codegen fails on windows with Error: No operations or fragments found to generate code for #2667

Open
Zikoat opened this issue Nov 14, 2022 · 0 comments

Comments

@Zikoat
Copy link

Zikoat commented Nov 14, 2022

Problem

After updating apollo to 2.34.0, i get an error on windows when generating typescript code:

Error: Command failed: apollo client:codegen --localSchemaFile=C:\companyname\__generated__\schema.json,C:\companyname\src\clientSchema.graphql --target=typescript --includes=C:\companyname\src\**\*.graphql --globalTypesFile=./__generated__/globalTypes.ts --suppressDeprecationWarning --excludes=C:\companyname\src\clientSchema.graphql

⚠️  It looks like there are 0 files associated with this Apollo Project. This may be because you don't have any files yet, or your includes/excludes fields are configured incorrectly, andd Apollo can't find your files. For help configuring Apollo projects, see this guide: https://go.apollo.dev/t/config

    Error: No operations or fragments found to generate code for.

Solution

Change backslashes to forwardslashes.

-npx apollo client:codegen --localSchemaFile=C:/company/__generated__/schema.json,C:/company/src/clientSchema.graphql --target=typescript --includes=C:/company/src/**/*.graphql --globalTypesFile=./__generated__/globalTypes.ts --suppressDeprecationWarning --excludes=C:/company/src/clientSchema.graphql;
+npx apollo client:codegen --localSchemaFile=C:\company\__generated__\schema.json,C:\company\src\clientSchema.graphql --target=typescript --includes=C:\company\src\**\*.graphql --globalTypesFile=./__generated__/globalTypes.ts --suppressDeprecationWarning --excludes=C:\company\src\clientSchema.graphql;

Why does this happen?

[email protected] uses [email protected] which upgrades glob from ^7.1.3 to ^8.0.0, which has a breaking change which makes it use backslashes as escape characters instead of path separators on windows.

A fix would be to normalize the paths to unix-style using the normalize-path package before using glob to find files to transform, but because this package is deprecated i just wanted to document a potential fix for this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant