pg_graphql
pg_graphql copied to clipboard
Composite Type Support
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?
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.
Any timeline on this??
No exact timeline yet. We're currently working on upsert
support