Skip to content

NavType is not generated when used as a part of OpenResultRecipient #730

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

Open
sonrohan opened this issue Mar 27, 2025 · 3 comments
Open
Labels
feedback needed Extra attention is needed

Comments

@sonrohan
Copy link

sonrohan commented Mar 27, 2025

For example,

this works:

@Destination<ExternalModuleGraph>
@Composable
fun SomePage(
    someResult: SomeResult,
) {

}

@Parcelize
data class SomeResult(
  val data: String,
  val xyz: Int,
)

But this does not

@Destination<ExternalModuleGraph>
@Composable
fun SomePage(
    someResult: OpenResultRecipient<SomeResult>,
) {

}

@Parcelize
data class SomeResult(
  val data: String,
  val xyz: Int,
)

The issue is that when I use OpenResultRecipient, the resulting someResultNavType is not generated.

I did not see documentation about this, but it feels like a bug to me.

@sonrohan
Copy link
Author

sonrohan commented Mar 28, 2025

Do I need to write custom serializers for these now? Or is it a bug/gap @raamcosta ? It seems that it is able to create the file via ksp just fine when I do something like the top example, so it feels wasteful for me to write that serializer manually if it seems ksp can do it just fine.

Thanks!

@sonrohan
Copy link
Author

I found a sort of "workaround", though it feels incorrect.

You can force it to generate these files by creating a dummy nav graph and marking these values within a wrapper data class (parcel).

@Parcelize
data class NavArgsWrapper(
    val someResult: SomeResult,
    ...
) : Parcelable

@NavHostGraph
annotation class AppNavGraph {
    @NavGraph<AppNavGraph>(
        navArgs = NavArgsWrapper::class,
    )
    annotation class SomeGraph

@raamcosta
Copy link
Owner

@sonrohan how are you passing back that result? Do you not have a ResultBackNavigator as a parameter of a Destination annotated Composable? 🤔

@raamcosta raamcosta added the feedback needed Extra attention is needed label May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback needed Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants