Database & APIs

I have an issue with how flutterflow is handling a supabase api query. Any suggestions would be very much appreciated.

Problem

It seems to be failing because it is calling toList() on a null value.

However, it should not need to call toList(). It does this even if I am not using that json path at all in the app.

  • The Test Response works. There's no problem with the query.

  • The app works if I remove the join that yields the array on the json path. There is no dependency yet.

API Query

https://12345678.supabase.co/rest/v1/reviews_feed?
  select=*,
  reviews_bookmarks!review_bookmarks_review_id_fkey(user_id,review_id)
  &reviews_bookmarks.user_id=eq.[userID]
  &order=id.desc

Test Response (it works)

  1. Notice that some reviews have 1 bookmark. Some have zero.

{
    "id": 33,
    "review": "Cool",
    "username": "bot bot",
    "user_id": "5282058",
    "reviews_bookmarks": []
  },
  {
    "id": 32,
    "review": "beep",
    "username": "not a bot",    
    "user_id": "5282058", 
    "reviews_bookmarks": [
      { "user_id": "6f9c13e4-b1be-4edd-915b-2e8d7472ceea" }
    ]
  },

Error

nosuchmethoderror: 'toList' 
Dynamic call of null. 
Receiver instance of '_JsonMap'
Arguments: []

Fixes

My goal is know which reviews the current user has bookmarked. The query filters bookmarks to the current user, so the array always has 1 or zero elements. Never more. I only need to check if the path has data or is null.

  1. One fix would be to understand why flutterflow is calling toList() and prevent that.

  2. Another fix would be to adjust my query so that the json doesn't have an array, since I don't need that.

Any advice would be very much appreciated.

What have you tried so far?

Component Setup

1) I have temporary removed the feature that uses `$.reviews_bookmarks` to debug. It still fails.

2) I have confirmed that the app works if I remove the table join from the query

3) I have confirmed that the API Test Response works if I keep the table join in the query

4) I have also considered approaches that are very different than this API, such as storing a user's list of bookmarks in state, and then checking the reviews list against that. Other solutions are either not scalable or require a bunch of state management that is at risk of falling out of sync.

Did you check FlutterFlow's Documentation for this topic?
Yes
1