apollographql / apollographql/apollo-tooling

[Feature Request] Allow option to remove/omit fragment prefix naming for better re-use

Open
#1,207 1 comment 0 reactions 0 assignees View on GitHub
:tada: feature 🤖 component - codegen
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

I'm seeing the benefits of not prefixing generated fragments with the parent's name.

Current:
```javascript
export interface RestaurantFragment {
__typename: "Restaurant";
menus: MenuFragment_restaurant | null;
}

export interface MenuFragment_restaurant {
__typename: "Menu";
name: string;
}
```

Proposed:
```javascript
export interface RestaurantFragment {
__typename: "Restaurant";
menus: MenuFragment_restaurant | null;
}

export interface MenuFragment {
__typename: "Menu";
name: string;
}
```

In the second case, the `MenuFragment` will be the same at all levels in the GraphQL data tree, whereas the current method will prefix the fragment with the parent fields name, making re-use much more difficult.

Contributor guide

Open the contributing guide

Research direction

No source file, test, or entry point is named. Start by locating the TypeScript GraphQL fragment-name generation path and its option handling, then add coverage showing that nested fragments can omit the parent-name prefix and produce the proposed reusable names.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.