0

I am trying to insert an array of objects to my hasura table. I have defined my columns like the image below

Table Columns

But I am receiving malformed array literal: \"[]\" error. I am using JSON.stringify from my client side code to stringify my array before calling the mutation. What am I doing wrong?

Natnael
  • 59
  • 12
  • I'm not sure about this, but shouldn't you need to use `JSON.parse` on your data before using it ? – Tenclea Oct 28 '21 at 14:56
  • Hasura(GraphQL) expects variables to be string `"message": "A string is expected for type: _json"` – Natnael Oct 28 '21 at 19:53

1 Answers1

2

I'd highly recommend that you just make the column a jsonb and then store the array directly. jsonb querying capabilities are significantly improved over json and Hasura doesn't have the greatest support for array columns (of any type).

When submitting data to an array column with Hasura it expects to receive it as a string using the PG array literal syntax, eg '{1, 2, 3}' for an int[] column.

Jesse Carter
  • 20,062
  • 7
  • 64
  • 101