Given this SQL schema:
CREATE TABLE public."table" (
"textArray" text[]
)
Graphql engine returns an error when trying to mutate:
{
name: 'FormatedError',
message: 'Unknown error',
originalError:
{
path: '$.variableValues[0].textArray',
error: 'A string is expected for type : _text',
code: 'parse-failed'
}
}
Is there a workaround? Many thanks
@sulliwane You can pass the array value as text since all postgres types which are not natively supported by GraphQL Engine are treated as text.
This mutation will go through:
mutation {
insert_table(objects:{
textArray: "{hello, world}"
}) {
returning {
textArray
}
}
}
with response:
{
"data": {
"insert_table": {
"returning": [
{
"textArray": [
"hello",
"world"
]
}
]
}
}
}
thanks a lot, it works perfectly!
About the curly brackets {} for the array, may I ask what kind of "standard" is that (obviously not JSON format) is it related to graphql or postgres or hasura?
{} is how arrays are represented in Postgres [1]
Ok, got it. closing then, thanks a lot @shahidhk
Most helpful comment
@sulliwane You can pass the array value as text since all postgres types which are not natively supported by GraphQL Engine are treated as text.
This mutation will go through:
with response: