dotansimha / dotansimha/graphql-code-generator

NamingConvention is incorrectly applied for typescript-urql-graphcache nodes when typesPrefix is used and entities start with lowercase

Open
#7,853 0 comments 0 reactions 0 assignees View on GitHub
core
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Issue workflow progress

_Progress of the issue based on the [Contributor Workflow](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md#a-typical-contributor-workflow)_

- [x] 1. The issue provides a reproduction available on [Stackblitz](https://stackblitz.com/edit/github-abkvqw-gln2vs?file=types.ts)
- [ ] 2. A failing test has been provided
- [ ] 3. A local solution has been provided
- [ ] 4. A pull request is pending review

---

**Describe the bug**

If the name of a GraphQL-Type does not start with a capital letter, the case of the generated graphcache-types are incorrectly cased:
`schema.graphql`
```graphql
type user {
id: ID!
username: String!
email: String!
}
```

`types.ts` (generated)
```typescript
// [...]
export type GqlUser = {
__typename?: 'user';
email: Scalars['String'];
id: Scalars['ID'];
username: Scalars['String'];
};
// [...]
export type GraphCacheKeysConfig = {
user?: (data: WithTypename) => null | string
// ^^^^^^^ ERROR
}
```

**I think, it may be, that the `convertNaming` function is applied to the prefix as well. Fixing this would probably also fix this issue:** dotansimha/graphql-code-generator-community#170
I'm really not into your codebase, otherwise I would like to provide a pull-request.

**To Reproduce** check Stackblitz example.

**Expected behavior**

Correctly cased types for graphcache:
`types.ts`
```graphql
export type GraphCacheKeysConfig = {
user?: (data: WithTypename) => null | string
}
```

**Environment:**
```
"@graphql-codegen/add": "^3.1.1",
"@graphql-codegen/cli": "^2.4.0",
"@graphql-codegen/typescript": "2.4.11",
"@graphql-codegen/typescript-operations": "2.4.0",
"@graphql-codegen/typescript-urql-graphcache": "2.2.13",
"graphql": "^16.2.0"
```

**Additional context**

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.