apollographql / apollographql/apollo-tooling
Codegen does not automatically append "Query" or "Mutation" to the generated type
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
Hi 👋
In the docs, I came across this section:
Given this query:
```typescript
query Characters {
characters(episode: NEW_HOPE) {
name
... on Human {
homePlanet
}
... on Droid {
primaryFunction
}
}
}
```
Apollo Codegen will generate a union type for Character.
```typescript
export type CharactersQuery = {
characters: Array<
| {
__typename: "Human",
name: string,
homePlanet: ?string
}
| {
__typename: "Droid",
name: string,
primaryFunction: ?string
}
>
};
```
When I run this command, I do not get "Query" or "Mutation" appended to the generated type. Instead mine is just `type Characters`. Can I solve this without having to rename all my queries _and_ mutations?
What am I doing wrong? Do I need to configure something? Or does my `schema.json` file need to have a certain key? Any help would be appreciated!
Contributor guide
Research direction
Start by reproducing the documented Characters example and comparing its generated CharactersQuery with the reported Characters output. Trace the codegen naming path and inspect the configuration or schema inputs involved; done means the suffix behavior is corrected or its required configuration is documented, with a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100