Complex schema in terraform provider

Hi,

I am trying to add resource to a provider with a complex schema,
the requirement is to support also subset of the schema.

for example:

{
    field1 = true
    a {
           field_a1 = ["foo"]
           field_a2 = true
           b {
                   field_b1 = "some_string"
               }
       }
}

I need to support the following:

{
    a {
           field_a1 = ["foo"]
           b {
                   field_b1 = "some_string"
               }
       }
}

and

{
    field1 = true
   
}

and

{
    field1 = true
    a {
           field_a1 = ["foo"]
         
       }
}

and

{
    field1 = true
    a {
           b {
                   field_b1 = "some_string"
               }
       }
}

the missing fields will get the default values in the backend

I think I managed to get the DTO send to the server as expected
by using pointers both for the bool and struct fields
to distinguish between null and false etc…

but in the schema side I cant make it works, tried all combinations of Optional,Computed and Default
when I remove a field from the tf file terraform recognise the change and assign the default value as expected but when I remove sub entity (b for example) terraform apply return with no change.

can you please advise?

this is how the schema is defined:

func resourceA() *schema.Resource {
	return &schema.Resource{
		CreateContext: resourceAUpdate,
		ReadContext:   resourceARead,
		UpdateContext: resourceAUpdate,
		DeleteContext: resourceADelete,
		Schema: map[string]*schema.Schema{
			"id": {
				Type:        schema.TypeInt,
				Optional:    true,
			},
			"a": {
				Type:        schema.TypeList,
				MaxItems:    1,
				Optional:    true,
				Default:     nil,
				Elem: &schema.Resource{
					Schema: map[string]*schema.Schema{
						"b": {
							Type:        schema.TypeList,
							MaxItems:    1,
							Optional:    true,
							Default:     nil,
							Elem: &schema.Resource{
								Schema: map[string]*schema.Schema{
									"field_b1": {
										Type:        schema.TypeBool,
										Optional:    true,
										Default:     false,
									},
								},
							},
						},
						"field_a1": {
							Type:        schema.TypeBool,
							Optional:    true,
							Default:     true,
						},
					},
				},
                              "field1": {
							Type:        schema.TypeBool,
							Optional:    true,
							Default:     true,
						},
			},
		},
	}
}