Apollo scalar type in android-kotlin

I am trying to execute a graphql mutation via apollo on android.
For example I have this:

    mutation allData($filter: DataFIlter) {
      data: listData(
        filter: $filter
      ) {
        items {
          ...DataFragment
        }
      }
    }

and I need to send Json like this:

{
  "filters": [
    {
      "atr1": "...",
      "atr2": "...",
    }
  ],
{...}
]
}

But DataFilter is scalar type that don’t described on schema.json. In my generated “AllDataMutation()” type of parametr “dataFilter” is “Any?”. What should i pass to this function?

Hi !

You should be able to pass a regular Kotlin object where Json objects are mapped to Kotlin Map and Json arrays to Kotlin List:

AllDataMutation(
    mapOf("filters" to listOf(
        mapOf(
            "atr1" to value1, 
            "atr2" to value2
        ),
    )

If you want more type safety, you can also register your custom scalar and Adapter. See https://www.apollographql.com/docs/android/essentials/custom-scalar-types/ for more details