Add ability to create double value for custom objects #1793
Closed
magrinj
started this conversation in
Engineering vision
Replies: 1 comment
-
Double-text field type should not be universally available as it's an exception we're using specifically for our People and company standard object. Also, it's important to note that the goal is not limited to creating double values as mentioned in the issue title. The ability to have multiple key/value pairs is also crucial, such as including the currency exchange rate for the given "amount type" example. (Later, it's just an example) We should store the amount as an integer and use "cents" to prevent computation errors. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context
To elevate our platform experience and adhere to our dedication towards versatility, we've successfully added the integration of custom objects and fields into "Twenty". More on this can be found in Discussion #1142. This initiative now lets users across different workspaces seamlessly access custom objects using a dynamic GraphQL schema.
How it's currently working
Custom objects trace their roots back to metadata tables that dictate the shape, name, and type of the objects. All this information is housed in the metadata schema database, consisting of tables:
DataSource
Field
Introduction to a New Concept
Our vision is to evolve the
Field
type. We currently restrict to the following types:uuid
,text
,url
,date
,boolean
,number
, andenum
. We are now aiming to expand this list with entries such asdouble-text
andamount
. These new data types would potentially offer multi key/value storage under a single key.So for example if I've a type
amount
on a field, the generated resolver should serve something like this:Proposals
Use a JSON/JSONB Column
For complex types like
double-text
oramount
, we can use a JSON or JSONB column type.This approach benefits from flexibility since JSON/JSONB columns can store arbitrary nested data structures. In the GraphQL layer, and we can interpret and expose these as required:
Pros:
Cons:
Field Configuration Column
Add a configuration column (of type JSON/JSONB) in the Field table that defines the shape and attributes of the complex type. This way, we don't need extra tables, and we can still capture the additional attributes of complex types.
Pros:
Cons:
Composite Fields
In
FieldMetadata
, we can introduce a notion of "group" or "composite key". This means that fields like value and currency will be associated under a common composite key, such as amount.Modify
FieldMetadata
:For instance:
Field:
amount_value
, compositeKey:amount
, displayName:Amount
Field:
amount_currency
, compositeKey:amount
, displayName:Currency
Pros:
Cons:
Add a ViewMetadata layer
ViewMetadata
approach decouple the storage structure from the presentation structure. It will essentially allow to define how different FieldMetadata entries should be combined and presented in the GraphQL API. Here's a conceptual breakdown of how this can work:Create
ViewMetadata
andViewFieldMetadata
entities:This will act as a bridge between
ViewMetadata
andFieldMetadata
, enabling to define how individual fields (or groups of fields) should appear under a view.Then we can base our GraphQL resolvers on
ViewMetadata
:Fetch the relevant
ViewMetadata
based on the GraphQL query.For each
ViewFieldMetadata
within that view, retrieve the data from the associatedFieldMetadata
(and its linked table/column).Pros:
Cons:
Beta Was this translation helpful? Give feedback.
All reactions