apollographql / apollographql/apollo-tooling

apollo client:codegen does not respect config tag, only explicit —tag argument

Open
#995 2 comments 0 reactions 0 assignees View on GitHub
🤖 component - codegen
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

**Intended outcome:**
I'm trying to push use codegen for my queries using `client:codegen`, and expect the CLI to respect the Apollo config

**Actual outcome:**
The command does not respect the config, and only works if I explicitly pass `--tag=mytag` to the command, otherwise it defaults to `@current`

**How to reproduce the issue:**

1. Have a service on the Apollo platform
2. Push a schema to a specific tag, i.e. `production`, `beta` etc.
3. Push a different, flawed/older schema to `current`
4. Try to codegen on your client using the `client:codegen` command and having set a tag in your config file
5. See the codegen fail, citing errors in the queries against the schema that match the differences between your `current` and `production` schemas.
6. Add `--tag=yourtag` to the CLI command, and see the codegen work

**Versions**
Using `apollo` v `2.4.4`.

**Extra info**
My config:

```
module.exports = {
client: {
service: 'myservice@production',
name: 'react-app',
version: '1.0.1',
includes: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.graphql'],
},
engine: {
apiKey: '...,
},
};
```
The commands:
`"apollo-push": "apollo client:codegen",` or
`"apollo-push": "apollo client:codegen --tag=\"production\"",`

Contributor guide

Open the contributing guide

Research direction

Start at the client:codegen CLI entry point and trace how the configured service tag is read versus the explicit --tag argument. Reproduce with the provided production/current schema setup and config, then verify that running client:codegen without --tag uses the configured tag and avoids the reported validation failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.