dotansimha / dotansimha/graphql-code-generator-community
URQL GraphCache creates type error when there are no mutations
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
### Issue workflow progress
- [x] 1. The issue provides a reproduction: https://github.com/matthew-petrie/graphql-code-generator-issue-sandbox-template
- [x] 2. A failing test has been provided (see linked PR)
- [x] 3. A local solution has been provided (see https://github.com/matthew-petrie/graphql-code-generator-issue-sandbox-template)
- [x] 4. A pull request is pending review
**Describe the bug**
The `typescript-urql-graphcache` plugin causes a typescript error in the generated type file for the type `GraphCacheOptimisticUpdaters` if the schema has no mutations:

**To Reproduce**
Reproduction repo: https://github.com/matthew-petrie/graphql-code-generator-issue-sandbox-template
Steps to reproduce the behavior:
1. My GraphQL schema:
```graphql
type Query {
user(id: ID!): User!
}
type User {
id: ID!
username: String!
email: String!
}
```
2. My GraphQL operations:
```graphql
query user {
user(id: 1) {
id
username
email
}
}
```
3. My `codegen.yml` config file:
```yaml
schema: schema.graphql
documents: document.graphql
generates:
types.ts:
plugins:
- typescript
- typescript-operations
- typescript-urql-graphcache
```
**Expected behavior**
For `typescript-urql-graphcache` to generate a types file with no Typescript errors. If there are no mutations `GraphCacheOptimisticUpdaters` should be output as:
```graphql
export type GraphCacheOptimisticUpdaters = {};
```
**Environment:**
- OS: macOS Monterey 12.3 - M1 Pro chip
- `@graphql-codegen/typescript-urql-graphcache`: ^2.2.13
- `typescript`: ^4.7.2
- NodeJS: v16.13.1
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.