-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Is your feature request related to a problem? Please describe.
defer and error on non nullable handling
schema:
type Query {
"""
Error simulator
"""
errorSimulator: ErrorSimulatorResult
}
type ErrorSimulatorResult {
field: String
resolve(delay: Int, err: Boolean!): ErrorSimulatorResult
@goField(forceResolver: true)
resolve2(delay: Int, err: Boolean!): ErrorSimulatorResult!
@goField(forceResolver: true)
}
query:
errorSimulator {
resolve2(delay: 500, err: false) {
field
... on ErrorSimulatorResult @defer {
failed: resolve2(delay: 1000, err: true) {
field
}
}
... on ErrorSimulatorResult @defer {
success: resolve2(delay: 100, err: false) {
field
}
}
}
}
this causes
Uncaught TypeError: Cannot read properties of undefined (reading 'field')
code: data?.t2?.resolve2.failed.field
stack:
- @apollo/client 3 or 4
- graphql-sse ^2.5.4
- @graphql-codegen/cli: ^5.0.2
Describe the solution you'd like
mark as optional all fields parent of a @defer
on non-nullable field (can be an opt-in config?)
Describe alternatives you've considered
No response
Any additional important details?
I think this is partially due to the specs mess that defer is today, should resolve itself, but in the mean time, this bandaid would allow for safe code to be generated until this is all figured out
Metadata
Metadata
Assignees
Labels
No labels