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

Add document on how to **rename** the fields in a object. #166

Open
Taskeren opened this issue Jan 20, 2025 · 2 comments
Open

Add document on how to **rename** the fields in a object. #166

Taskeren opened this issue Jan 20, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@Taskeren
Copy link

Tested that none of @SerialName and @JsonProperty works with KGQL, and it seems that the document didn't mention it.
It would be nice if we have more details on how KGQL serialize and deserialize the objects

Example

@Serializable
data class UserDto(
	@SerialName("_id")
	@JsonProperty("_id")
	val id: String,
)

And it still uses id but not _id.

@stuebingerb stuebingerb added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 20, 2025
@stuebingerb
Copy link
Owner

stuebingerb commented Jan 20, 2025

From first look it doesn't seem possible. You can try to ignore id and add a new _id property but I'm not sure how this behaves end-to-end, especially for mutations:

type<UserDto> {
    property(UserDto::id) {
        ignore = true
    }
    property("_id") {
        resolver { user: UserDto -> user.id }
    }
}

And of course this might not be feasible for actual use cases. IMHO looks like a valid feature request.

@stuebingerb stuebingerb removed the documentation Improvements or additions to documentation label Jan 20, 2025
@Taskeren
Copy link
Author

Thanks for answering.
Hope to see it become available as a new feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants