smallrye-graphql
smallrye-graphql copied to clipboard
Dependency on yasson
I just found the following code in RequestImpl
that necessitates the dependency on yasson, which we should get rid of.
try (Jsonb jsonb = JsonbBuilder.create()) {
JsonStructure struct = ((JsonBinding) jsonb).toJsonStructure(v);
varBuilder.add(k, struct);
} catch (Exception ignore) {
}
Why is this not simply varBuilder.add(k, jsonb.toJson(v));
and why is the exception ignored?
If there is a valid reason, this deserves a comment. Anyone any idea? @hogmuzzle maybe?
Sorry, I meant varBuilder.add(k, Json.createReader(new StringReader(jsonb.toJson(v))).read());
If this is about performance, has anybody measured that? I think the JDK might very well be able to inline this.
We bring in Yasson anyway so I guess using its classes wasn't considered a problem, but if we can remove that, then why not.
I'm not sure how often that branch is used though - if it's a complex Json object, that's caught already by else if (v instanceof JsonValue)
no?
We bring in Yasson anyway so I guess using its classes wasn't considered a problem, but if we can remove that, then why not.
It's also a dependency in the client/implementation
module, but it's not used anywhere. Maybe we should make it optional or even remove it: BYOJB - bring your own JsonB 😁 In the server, it's only a test dependency.
I'm not sure how often that branch is used though - if it's a complex Json object, that's caught already by else if (v instanceof JsonValue) no?
That catches the JsonValue
parameters, but that final else
is for arbitrary Java objects.