Skip to content
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

Update Javadoc of retrieve in GraphQlClient for decoding full data #434

Closed
kitkars opened this issue Jul 4, 2022 · 5 comments
Closed

Update Javadoc of retrieve in GraphQlClient for decoding full data #434

kitkars opened this issue Jul 4, 2022 · 5 comments
Assignees
Labels
type: documentation A documentation task
Milestone

Comments

@kitkars
Copy link

kitkars commented Jul 4, 2022

Hi Spring Team,

It is a request / question.

Can you provide an additional overloaded method .retrieve() in the GraphQlClient's RequestSpec if the users want to access the whole data response?

We do have some work around as shown here but it would be better to have it part of RequestSpec itself.
.retrieve("")
or
execute().map(...)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 4, 2022
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Jul 8, 2022

Generally, execute is for access to the full response and you can can convert the entire data from there:

.execute().map(response -> response.toEntity(...))

We could consider retrieve() without any arguments but it seems like most often, you'll have at least a top-level path to go navigate? Could you clarify on the scenario, does the data contain multiple keys, and what would you decode to?

@rstoyanchev rstoyanchev added the status: waiting-for-feedback We need additional information before we can continue label Jul 8, 2022
@kitkars
Copy link
Author

kitkars commented Jul 8, 2022

Thanks @rstoyanchev

Is it not normal to have multiple keys inside the data object? For ex: I ask for a book by id and along with some recommendations. (may be a bad example.) and I might want to map it to a BookWithRecommendationsDto. Others might not be interested in the recommendations and might be interested only in the book object.

{
    "data": {
        "book": {..},
        "recommendations": [
            { .. },
            { .. }
        ]
    }
}

It is not a blocker. Currently I could use .retrieve(""). But as you see it makes the code super ugly.
So adding a default retrieve() in the interface would be nice to have as we have in the WebClient.
If you have other plans to make it better, that would be great too. I can go with execute as well.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 8, 2022
@rstoyanchev
Copy link
Contributor

Multiple keys is no problem. This is what you can do right now:

.execute().map(response -> response.toEntity(BookWithRecommendationsDto.class))

I'll schedule this to add retrieve() as a shortcut for the above.

@rstoyanchev rstoyanchev self-assigned this Jul 8, 2022
@rstoyanchev rstoyanchev added type: enhancement A general enhancement and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Jul 8, 2022
@rstoyanchev rstoyanchev added this to the 1.0.1 milestone Jul 8, 2022
@rstoyanchev rstoyanchev changed the title Provide retrieve overloading method with empty path Add retrieve() without arguments to GraphQlClient to decode the full data Jul 8, 2022
@kitkars
Copy link
Author

kitkars commented Jul 8, 2022

Thank you sir, I appreciate it.

@rstoyanchev
Copy link
Contributor

On closer look, since the full data cannot be a List, the toEntityList methods don't make sense and would need to be implemented by raising an error. Even the Javadoc of retrieve is specifically positioned as a shortcut for a specific field. I'm afraid you'll have to rely on the version I suggested above in #434 (comment). I did update the Javadoc on retrieve and retrieveSubscription to make a note of this case so it's easy to find.

@rstoyanchev rstoyanchev changed the title Add retrieve() without arguments to GraphQlClient to decode the full data Update Javadoc of retrieve in GraphQlClient for decoding full data Jul 19, 2022
@rstoyanchev rstoyanchev added type: documentation A documentation task and removed type: enhancement A general enhancement labels Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

3 participants