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

Add support for `@Ignore(on=Type)` or `@Ignore(on=Input)`

Open t1 opened this issue 4 years ago • 11 comments

If a java class is used an Input as well as a Type, but there are resolver methods in the GraphQL service, then some fields are returned as output but not allowed as input (see also #517). Instead of defining two separate classes with most of the fields duplicated, it would be convenient to mark some fields as @NonInput, so the typesafe client checks that they are actually null and then doesn't send them at all to the service.

t1 avatar Nov 19 '20 11:11 t1

What about using @Ignore ? Use it on the setter to ignore the input and on the getter to ignore the output. Does that not do what you want ? (That is how the server works)

phillip-kruger avatar Nov 19 '20 12:11 phillip-kruger

Oh, yeah. I forgot about that one. Maybe @NonInput would still be more explicit? WDYT?

t1 avatar Nov 19 '20 15:11 t1

-1 for me, but I am happy to be convinced otherwise :)

phillip-kruger avatar Nov 19 '20 15:11 phillip-kruger

The trick with @Ignore isn't supported in the client. I could add that, but this would require explanation/learning. It's not obvious that ignoring a setter means it's not passed as an input.

But @OutputOnly is probably better than @NonInput, isn't it?

t1 avatar Nov 19 '20 18:11 t1

Yea I would still keep the server and client the same. Json works the same way, so it's not brand new logic.

phillip-kruger avatar Nov 19 '20 19:11 phillip-kruger

The client still has its own logic to recognize and handle fields. It would be a major change to use the code from the common module. I assume that this is a natural thing to do when switching to the dynamic client after it's finished.

t1 avatar Nov 20 '20 04:11 t1

We need to do what we want to see in the spec, and I believe that would be to sync the client and server. @andymc12 what do you think ?

phillip-kruger avatar Nov 20 '20 04:11 phillip-kruger

I totally agree that we'll have to do much more before it's ready to be lifted into the spec.

t1 avatar Nov 20 '20 05:11 t1

What about @Ignore(on=OUTPUT)

phillip-kruger avatar Dec 02 '20 16:12 phillip-kruger

@Ignore(on=OUTPUT) is what we've agreed on in the meeting.

t1 avatar Dec 04 '20 05:12 t1

This would be a change to the spec, as the @Ignore annotation is from the spec.

The suggestion to put @Ignore on the getter or setter only would require that the typesafe client even considers getters and setters.

A first fix for some cases would be to consider the @Ignore for the fields getting into the request.

t1 avatar Jan 29 '22 15:01 t1