-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typed Client: all classes for the possibleTypes have to be present #2224
Comments
Also I don't know if the error message SRGQLDC035010 is used somewhere else, but it would be better to say:
To help developers to understand what is going on. |
The fix is simple for this error is simple. For my example project: jmini/gitlab-experiments@7a4edce |
We could theoretically ignore unknown subtypes, but it doesn't sound very safe to me, it could lead to unexpected issues, for example, if the user wrongly declares the name of the type, then the object in the response would be silently skipped. |
@t1 any opinion on this? |
Yes I am also not sure about what is correct. What is sure with the current pattern:
Maybe the Server API design is not ideal: The WorkItem Type (kind OBJECT) have this field:
Without any filtering possibility. and the |
Do I get this right: it would work, if you would only receive the types you are interested in? In other words: it only fails, if you actually receive a type that you don't expect? So you want to filter some types on the client side. That feels to be going against a design goals of GraphQL: the client specifies exactly what they want. So I think it would be better (for the world, not necessarily for you at this moment ;-), if the API would allow that type of filtering on the Despite me being reluctant to add this, I've looked at the Typesafe Client code: the change would actually be quite simple. The Do you understand or even agree with my point of view? BTW: I completely agree on improving on the error message. |
I think we all agree on that point, but the GitLab server is what it is. I will not try to defend their pattern (that seems to be very UI/frontent driven at the end), but I don't think that there is too much data transported, since only the "widgets": [
{},
{},
{},
{
... content of WorkItemWidgetLabels
},
{},
{},
{},
{},
{},
{},
{
... content of WorkItemWidgetLinkedItems
},
{},
{},
{},
{},
{},
{}
] I agree that those For me this discussion is about the deserialization at client side. Currently we need one entry for each of the possible
For me this would go in the same direction as With that new config set to @Union
@JsonbTypeInfo(key = "__typename", value = {
@JsonbSubtype(alias = "WorkItemWidgetLabels", type = WorkItemWidgetLabels.class),
@JsonbSubtype(alias = "WorkItemWidgetLinkedItems", type = WorkItemWidgetLinkedItems.class)
})
@Name("WorkItemWidget")
public interface WorkItemWidget {
} --> which is great, because I only need those two case. Without this config, I have to fix the client like this jmini/gitlab-experiments@7a4edce on each schema change (each addition of a new Widget sub-type is breaking) But indeed, for users that have more control of the GraphQL server, this new config would not be necessary. I can understand if you reject this idea of introducing a config. Then this would just be a known fact and users like me needs to update their model, which is fine (maybe this GitLab use-case is a corner case) In all cases, the error message can be improved to help identifying which sub-type declaration is missing in which interface. |
Of course! You're right. The "filtering" already happens (practically) via the fragments you specify; the empty So forget what I've said before. This is a useful feature. Do you think you could create a PR for this? |
I am not yet really familiar with the code base. I would need some pointers:
|
sorry for the delay...
yes, sure.
We use MP Config. As a lot of config keys depend on a logical API client name (a.k.a.
The tests live in the |
On the GitLab GraphQL server (no password required), the
WorkItemWidget
type (kindINTERFACE
) has multiple possible types.You can run a query like this:
https://gitlab.com/-/graphql-explorer
With the java typed client, you need to have all the sub-types declared (as empty class), even if you are only interested in two widgets.
If one is missing (as in this example) you get this stacktrace:
Setting
allowUnexpectedResponseFields
does not help here.Complete project: https://github.com/jmini/gitlab-experiments/tree/main/smallrye-graphql-client
I am not sure if something can be done about this, but I wanted to share this with you (and it might help other users).
The text was updated successfully, but these errors were encountered: