Apollo-tooling: Glob pattern for `includes` flag on `client:generate` not finding any matches

Created on 30 Jun 2019  路  4Comments  路  Source: apollographql/apollo-tooling

I'm finding that all glob patterns fail to find matches, while includes values that don't have any patterns are successful.

For example, this finds no matches:

node_modules/.bin/apollo codegen:generate --localSchemaFile=graphql-schema.json --target=typescript --includes=src/client/store/*.ts --tagName=gql --addTypename --globalTypesFile=src/client/types/queries.ts queryTypes

But if I change --includes=src/client/store/*.ts to point to a single file, e.g. --includes=src/client/store/registry.ts, it does work. It doesn't seem to matter if I prepend ./ before the path, or use absolute paths.

I am using v2.15.0.

Most helpful comment

Ah, needed to put quotes around the glob: --includes='src/client/store/*.ts'

All 4 comments

Ah, needed to put quotes around the glob: --includes='src/client/store/*.ts'

Awesome thanks! It's all about quotes!

I'll add this here since I was lucky to find it accidentally after wading through the source: In next.js, when using parameters in routes, your files will have names such as [id].tsx. If you don't quote the argument to --includes, a glob will be resolved by your shell, and the internal glob logic of apollo-codegen will receive [id].tsx, which it seems is a glob instruction itself, and will then not yield the actual file as a result.

Ah, needed to put quotes around the glob: --includes='src/client/store/*.ts'

This should really be in the docs...

Was this page helpful?
0 / 5 - 0 ratings