https://kotlinlang.org logo
#graphql-kotlin
Title
# graphql-kotlin
r

rocketraman

08/14/2022, 4:11 PM
I use graphql-kotlin on top of Ktor. I have a situation in which I get occasional random and not easily reproducible network errors (
IOException: Broken pipe
) from my db driver. While I continue to investigate the root cause of this, I'd like to add a workaround with some retry logic. Since the underlying exception could occur pretty much anywhere, I'm thinking having the logic at the graphql-kotlin layer makes sense, if it is possible. What would the right way to do this? Would an interceptor work for this case?
In some cases, the error happens at the field level, and the
defaultDataFetcherExceptionHandler
is invoked for the entire message. Would be nice to be able to retry the fetch for just the field that failed, but I'd settle for retrying the entire thing.
d

Dariusz Kuc

08/14/2022, 11:01 PM
GraphQL engine is unaware of your fetch logic (you can pull the data from whatever sources) so I personally wouldn't try to modify graphql layer. IMHO you should retry your DB calls instead.
r

rocketraman

08/15/2022, 12:42 AM
Yeah that's what I ended up doing. Thanks!
a

Arnab

08/16/2022, 11:01 AM
You can wrap your fetching with something like https://stackoverflow.com/a/46890009
17 Views