Exception is thrown during multipart upload when field initially is not empty. #260
-
Is your feature request related to a problem? Please describe. I was trying to write a test for the Mutation using an apollo-android client. It has native Their And it is a plain string: The problem is Exception:
And there is not any simple solution to tune this process because:
Describe the solution you'd like I can suggest you add an ability to override this behavior somehow. I don't want an exception to be thrown when these values at multipart fields are not empty initially, but I understand, that some people want it and expect it to be strict. So I don't want this exception to be eliminated — leave it as is. You can make some setters to provide custom implementation and avoid using static calls because they can't be overridden. Describe alternatives you've considered I also will leave reference on that ticket at |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Submitted bug at client side: apollographql/apollo-kotlin#2409 |
Beta Was this translation helpful? Give feedback.
-
Found workaround import com.fasterxml.jackson.databind.ObjectMapper
import graphql.kickstart.execution.GraphQLObjectMapper
import graphql.kickstart.execution.GraphQLRequest
import graphql.kickstart.execution.config.ObjectMapperProvider
import graphql.kickstart.execution.error.GraphQLErrorHandler
import java.util.function.Supplier
class GraphQLObjectMapper(objectMapper: ObjectMapper, errorHandler: GraphQLErrorHandler? = null) :
GraphQLObjectMapper(ObjectMapperProvider { objectMapper }, Supplier { errorHandler }) {
override fun readGraphQLRequest(text: String?): GraphQLRequest =
super.readGraphQLRequest(text).apply {
if (variables.isNotEmpty()) {
variables = TrickyHashMap(variables)
}
}
private class TrickyHashMap<K, V>(m: MutableMap<K, V>, private val delegate: MutableMap<K, V> = HashMap()) :
MutableMap<K, V> by delegate {
override fun put(key: K, value: V): V? {
this.delegate[key] = value
return null
}
}
} and then @Bean
fun graphQLObjectMapper(objectMapper: ObjectMapper): GraphQLObjectMapper =
GraphQLObjectMapper(objectMapper, errorHandler()) |
Beta Was this translation helpful? Give feedback.
-
Hi guys, this bug is really a bad one. Could anybody look into it? |
Beta Was this translation helpful? Give feedback.
-
@meiblorn You mention that you understand that some people might want it strict. I'm just wondering what the effect could be if that if (null != mapper.set(currentLocation, segmentName, part)) {
throw new RuntimeException("expected null value when mapping " + objectPath);
} Making it configurable and/or overridable will mean considerable effort mainly to support a library that isn't sticking to the specification in the first place. I've noticed they've fixed it on their end in the mean time, so apparently it's not a problem anymore? |
Beta Was this translation helpful? Give feedback.
-
@meiblorn @m-o As I indicated a month ago it looks like they solved the issue on their end making their library in line with the specification. Can you confirm? Since our implementation is according to specification too, then I'd say we can close this issue. |
Beta Was this translation helpful? Give feedback.
-
This issue has been fixed client side in release 2.4.0. See also: apollographql/apollo-android#2409 |
Beta Was this translation helpful? Give feedback.
This issue has been fixed client side in release 2.4.0. See also: apollographql/apollo-android#2409