pg_graphql icon indicating copy to clipboard operation
pg_graphql copied to clipboard

Composite Type Support

Open olirice opened this issue 2 years ago • 3 comments

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)

  • Should sorting be allowed?
  • Filtering? Filtering on single attribute?
  • How/Should nested composites be allowed?

olirice avatar Feb 17 '23 20:02 olirice

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.

shanna avatar May 04 '23 13:05 shanna

Any timeline on this??

hchockarprasad avatar Apr 12 '24 18:04 hchockarprasad

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

olirice avatar Apr 12 '24 20:04 olirice