apollographql / apollographql/apollo-tooling
Add option to add prefix to generated types
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
In our code base we have a convention that all types are prefixes with a `T` for example `TProps`, `TQuery` or `TMutation`. It would be nice if we could generate flow types from graphql files which follow this convention.
This would solve also the problem that it's hard to import the type and the graphql-tag in the same file:
```graphql
// User.graphql
query UserQuery {
firstName
lastName
}
```
```js
import { UserQuery } from './User.graphql'
// We have to always rename the import because UserQuery already exists.
import type { UserQuery as TUserQuery } from './__generated__/UserQuery'
const User = () => (
{(props: QueryRenderProps) => null}
)
```
I am happy to create a MR if you can give me some hints how all the packages act together.
Contributor guide
Research direction
Start with the code-generation packages that produce Flow types from the User.graphql example and trace how generated type names are chosen. The change is done when callers can configure a prefix such as T and the generated imports use names like TUserQuery without requiring a rename.
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
- 38/100