supabase / pg_graphql

GraphQL support for PostgreSQL
https://supabase.github.io/pg_graphql
Apache License 2.0
2.92k stars 104 forks source link

Composite Type Support #319

Open olirice opened 1 year ago

olirice commented 1 year ago

Currently columns with composite types are filtered out for queries and mutations. They could be supported as shown below.

Translating from

create type "SemVer" as (
    major int,
    minor int,
    patch int,
    "preRelease" text[],
    "buildMetadata" text[]
); 

To

type SemVer {
  major Int
  minor Int
  patch Int
  preRelease [String]
  metadata [String]
}

Open questions (feel free to discuss below)

shanna commented 1 year ago

Support for select, insert and update (query/mutate) would be enough to unblock me. I've been using composite types instead of jsonb (and a schema) to group related fields (addresses, icalendar RRULE and RRULESETS etc) that are typed, structured and tightly coupled 1:1 with the row.

I've never written or seen a nested composite type in the wild though. I'm guessing as JSON support continues to improve in PG we might see more use of composite types as a document store without dumping everything in jsonb? If your document schema is well defined keep the strict parts as nested composite types and keep the unstructured parts as jsonb.

Sorting and filtering would be cool but I can always work around it with stored procedures.

hchockarprasad commented 7 months ago

Any timeline on this??

olirice commented 7 months ago

No exact timeline yet. We're currently working on upsert support