smallrye-graphql icon indicating copy to clipboard operation
smallrye-graphql copied to clipboard

No json object support in type-safe client.

Open Jacrispys opened this issue 3 years ago • 11 comments

No, it's not implemented, yet, and we'd have to decide about what json classes we'd support.

If you don't need the data field of your image class, just remove it! In fact, you should remove all fields that you don't need, not only because of the bloat in the payload, it could also be expensive for the server to fetch the data and/or count against your usage/complexity threshold.

Originally posted by @t1 in https://github.com/smallrye/smallrye-graphql/discussions/1454#discussioncomment-3211724

Jacrispys avatar Jul 26 '22 06:07 Jacrispys

Will link PR to solve…

Jacrispys avatar Jul 26 '22 06:07 Jacrispys

MicroProfile supports JSON-B, so that has to be supported. Other APIs like Jackson are optional.

t1 avatar Jul 26 '22 06:07 t1

Alright, I'll get a basic IMPL up tmrw if I have time!

Jacrispys avatar Jul 26 '22 06:07 Jacrispys

@t1 i plan on doing my homework tonight and reading src for where I need to PR, could you point me to the package I will mostly be working in for this?

Jacrispys avatar Jul 26 '22 07:07 Jacrispys

bump @t1 im not sure where to look to find where to add a new type to the type safe client.

Jacrispys avatar Jul 30 '22 05:07 Jacrispys

The code you'll need to change is mainly in client/implementation/src/main/java/io/smallrye/graphql/client/impl/typesafe/json.

Please remember to also add tests, probably to a new JsonBehavior class in client/tck/src/main/java/tck/graphql/typesafe.

t1 avatar Jul 30 '22 08:07 t1

Alright, sounds good thanks!

Jacrispys avatar Jul 30 '22 08:07 Jacrispys

Weird thing... When using the Jakarta JsonObject to parse, it gives this NPE image image

When navigating to the code in my fork, it points to the type being null: image

Which doesn't make sense, because to my knowledge the type field should just be getting object.class.getType() or something similar, which cannot be null.

Jacrispys avatar Jul 30 '22 22:07 Jacrispys

I'm not sure, but it could be that it recurses into the fields of the JsonObject class and some of those fields is generic, i.e. a ParameterizedType or so. I guess that's too deep, you'll have to stop it from recursing into JsonObject when building the query.

t1 avatar Aug 05 '22 08:08 t1