title: Androidx - How to handle Nested Graph's fragments from parent fragment using Navigation?
body: <p><a href="https://i.stack.imgur.com/n9oQp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/n9oQp.png" alt="enter image description here"></a></p>
  
  <p>Here is the scenario:- </p>
  
  <p>I am having a Main Activity which has root NavGraph and load fragment A as default. If I am moving from Fragment A to  Fragment B where I have  child fragment and TabLayout within it, So user can switch fragment within inside it , for which I have created a new nestedgraph for child fragment inside Fragment B. When I am moving from Fragment A to Fragment B , am able to show Fragment C within my child Fragment because I have set  start Destination as Fragment C in my nested Graph.</p>
  
  <pre><code>***root Navigation Graph***
  
  
  
       &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;navigation xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
                  android:id="@+id/navigation_graph"
                  app:startDestination="@id/fragmentC"&gt;
  
          &lt;fragment
                  android:id="@+id/FragmentA"
                  android:name="com.myapp.fragment.FragmentA"
                  android:label="Fragment A"
                  tools:layout="@layout/fragment_A"&gt;
              &lt;action
                      android:id="@+id/action_fragmentA_to_fragmentB"
                      app:destination="@id/fragmentB" /&gt;
          &lt;/fragment&gt;
          &lt;fragment
                  android:id="@+id/fragmentB"
                 android:name="com.myapp.fragment.FragmentB"
                  android:label="FragmentB"
                  tools:layout="@layout/fragment_B"&gt;
              &lt;action
                      android:id="@+id/action_fragmentB_to_second_graph"
                      app:destination="@id/navigation_graph2" /&gt;
          &lt;/fragment&gt;
  
          &lt;include app:graph="@navigation/navigation_graph2" /&gt;
  
      &lt;/navigation&gt;
  
  
      ***Nested Navigation Graph***
  
  
          &lt;?xml version="1.0" encoding="utf-8"?&gt;
          &lt;navigation 
      xmlns:android="http://schemas.android.com/apk/res/android"
                      xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
                      android:id="@+id/navigation_graph2"
                      app:startDestination="@id/FragmentC"&gt;
  
              &lt;fragment android:id="@+id/FragmentC"
                        android:name="com.myapp.fragment.FragmentC"
                        android:label="Fragment C"
                        tools:layout="@layout/fragment_C"&gt;
   &lt;action
                  android:id="@+id/action_fragmentC_fragmentD"
                  app:destination="@id/FragmentD" /&gt;
              &lt;/fragment&gt;
  
              &lt;fragment android:id="@+id/FragmentD"
                        android:name="com.myapp.fragment.FragmentD"
                        android:label="Fragment D"
                        tools:layout="@layout/fragment_D"&gt;
   &lt;action
                  android:id="@+id/action_fragmentD_fragmentC"
                  app:destination="@id/FragmentC" /&gt;
              &lt;/fragment&gt;
          &lt;/navigation&gt;
  
  ***Inside Fragment B***
  
  public class FragmentB extends BaseFragment&lt;FragmentAssignmentsBinding&gt;
          implements TabLayout.OnTabSelectedListener{
  
      NavController nestedNavController;
  
      @Override
      public int getLayoutId() {
          return R.layout.fragment_assignments;
      }
  
      @Override
      public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
          if(getFragmentDataBinding()==null)
              return;
          nestedNavController = Navigation.findNavController(view);
          getFragmentDataBinding().myTabLayout.addOnTabSelectedListener(this);
      }
  
  
  
      @Override
      public void onTabSelected(TabLayout.Tab tab) {
  
          switch (tab.getPosition()) {
              case 0:
    //***Here  how to handle the nested graph Fragment Action ?***      
               nestedNavController.navigate(R.id. action_fragmentC_fragmentD);
  break;
              case 1:
                   nestedNavController.navigate(R.id. action_fragmentD_fragmentC);
                  break;
          }
  
      }
  
      @Override
      public void onTabUnselected(TabLayout.Tab tab) {
  
      }
  
      @Override
      public void onTabReselected(TabLayout.Tab tab) {
  
      }
  }
  </code></pre>
  
  <p>Now the issue is - > onClicking Tab A or Tab B from parentFragment( Fragment B) , I have to access nested NavGraph actions to replace fragment inside parentFragment.But come across with error :-</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: navigation destination
    com.myapp:id/action_fragmentC_fragmentD is
    unknown to this NavController</p>
  </blockquote>
  
  <p>Any help or guidance will be really helpful .</p>