Graphql-engine: better support for postgres array/hstore types

Created on 3 Sep 2018  Â·  22Comments  Â·  Source: hasura/graphql-engine

Currently the input for an array is a literal, i.e for a column of type text[] the input value has to be a string as follows: "{hello,world}". We should do the appropriate mapping to json arrays.

server intermediate enhancement high

Most helpful comment

Most importantly, would like to see _contains support on arrays

All 22 comments

via Pum on discord

This works when the literal is typed out in the body of the query, but I can't even get the string syntax to work when the value is passed in as a variable.

Actually, turns out that variables work as long as their type is _text and not String.

We should also be supporting the common operators on arrays like we did for json/jsonb.

Most importantly, would like to see _contains support on arrays

Till we add this, as a workaround, you can use JSONB and store JSON encoded
arrays. We have a support for a bunch of operators including some that
have contains type functionality.

On Sun, 3 Feb 2019 at 7:32 AM, Syed Jafri notifications@github.com wrote:

Most importantly, would like to see _contains support on arrays

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/hasura/graphql-engine/issues/348#issuecomment-460016048,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAIAWA9mqDzYSsvacwZ-bZUkajdJFSHOks5vJkMcgaJpZM4WXXKh
.

@coco98 I have seen the @> contains support for JSONB, the problem is that primitive arrays provide statistics, and are thus more efficient in queries.

Is there an update on this.
it's getting really hard updating the arrays, no mapping...
we always need to do some hacks to accomplish those simple operations.

Hi @yassinebridi, https://github.com/hasura/graphql-engine/pull/2243 had to be aborted to handle some edge cases. We'll be picking this up again in a couple of weeks.

What can we do for now instead... without resorting to implementing custom server just to have a single endpoint for this exact query?

If there's none, then I guess that's how it should be.

fyi just knowing that the right format for text[] is {hello,world} solved my problem (obvious in retrospect) — consider adding it to docs

@gunar you can find this in our docs here 🙂

@marionschleifer that's great, thank you! — your docs are impeccable.

Still excitedly waiting for #2243 !

@0x777 Can text[] be accessed through the console?

@JorgeCeja This issue is for server. Suppose for array types in console is here: https://github.com/hasura/graphql-engine/issues/2544

Array Support PLZ and Thank you! I am enjoying Hasura

Any update on how we can use array and what will be the type of field for it in hasura?
https://hasura.io/docs/1.0/graphql/manual/mutations/insert.html#insert-an-object-with-an-array-field
This is not working and sending back as string and also there is no text[] or _text in field types in hasura.

Is it possible or planned to have the _contains filter type for arrays? Arrays seem to work in general but not for filtering.

@JorgeCeja , @AkshayCloudAnalogy .. there's a way to "access" the text[] through the console (I know, it's a hack 😅)

Here's a gif showing how:

  • you can write the "[]" symbol after selecting the "text" type

array

I migrated a column from jsonb to text[], defined __text: string[] in codegen.yml and generated typescript types. The type of queried data was cool, but I found out I can't insert arrays to the field because the data should be in this array literal format... Looking forward to this issue being addressed.

Was this page helpful?
0 / 5 - 0 ratings