dotansimha / dotansimha/graphql-code-generator-community
Typescript Error: WithTypename type makes all properties optional which conflicts with updateQuery function
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
### Describe the bug
The bug is explained here: https://github.com/dotansimha/graphql-code-generator/issues/7447
You can see an image of the typescript error here, the code snippet comes from this [file](https://github.com/AndysonDK/syncbase/blob/f9fcc30604dddbeee82a5ec69b74a72887825b79/packages/web/src/graphql/client.ts#L20-L65):
Here you can also see the typescript error in a failed GitHub CI run:
https://github.com/AndysonDK/syncbase/runs/7416169280?check_suite_focus=true
### Your Example Website or App containing the error
https://github.com/AndysonDK/syncbase/tree/f9fcc30604dddbeee82a5ec69b74a72887825b79
### Steps to Reproduce the Bug or Issue
Clone this exact code: https://github.com/AndysonDK/syncbase/tree/f9fcc30604dddbeee82a5ec69b74a72887825b79
You only need to run the [typecheck script](https://github.com/AndysonDK/syncbase/blob/f9fcc30604dddbeee82a5ec69b74a72887825b79/packages/web/package.json#L11) in the web folder to see the type errors occurring
### Expected behavior
The type error shouldn't appear, the type should probably preserve the original type, but apparently that messes with this issue: https://github.com/FormidableLabs/urql/issues/2502
Also see this:
https://github.com/dotansimha/graphql-code-generator/pull/8062#issuecomment-1188820460
I should've added tests to my [PR ](https://github.com/dotansimha/graphql-code-generator/pull/7681) to prevent reversion of important changes
### Platform
Here are the `graphql-codegen` packages + the `graphql` package used in the project:
```JSON
"@graphql-codegen/cli": "2.9.0",
"@graphql-codegen/typed-document-node": "^2.3.2",
"@graphql-codegen/typescript": "2.7.2",
"@graphql-codegen/typescript-operations": "2.5.2",
"@graphql-codegen/typescript-urql-graphcache": "^2.3.2",
"graphql": "^15.8.0"
```
I'm running on WSL 2 with the following Linux distro:
```
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
```
node version: `v16.13.0`
### Codegen Config File
```JSON
"codegen": {
"watch": true,
"schema": "../server/schema.graphql",
"documents": "src/graphql/**/*.graphql",
"generates": {
"./src/graphql/generated.ts": {
"config": {
"defaultScalarType": "string"
},
"plugins": [
"typescript",
"typescript-operations",
"typed-document-node",
"typescript-urql-graphcache"
]
}
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.