You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately, I encountered the following error while attempting to generate TypeScript code:
Error: Failed cli executionCaused by:
0: Failed parsing config1: Parsing schema file for config2: Failed converting schema doc to schema struct3: No type definition 'OneOrTwo' exists in schema
The workaround suggestion was to use an enum, but this doesn't allow for complex payloads, which I need.
Request
It would be great if the schema could support a jsonb type, like so:
typeMyEntity {
id: ID!oneOrTwo: Jsonb
}
This way, the oneOrTwo field could accept any valid JSON, significantly simplifying the table layout and improving flexibility in handling different object types.
The text was updated successfully, but these errors were encountered:
I've added Jsonb as a feature request on our backlog. For the mean time to unblock you could use a string field and serialize your json.
It's unlikely we will support union types natively in the near future. Perhaps I can suggest you model your data with a nullable relationship field for both your entity One and Two. You can also model an algebraic enum (with a complex payload) just using an enum tag field.
For eg.
typeOne {
id: ID!text: String!
}
typeTwo {
id: ID!text: String!value: BigInt!
}
enumTag {
ONE TWO
}
typeMyEntity {
id: ID!tag: Tag!one: Onetwo: Two
}
Then based on the tag you can look up the related entity, and only set the relevant payload.
Description
Currently, I am trying to define a GraphQL schema that includes a field capable of representing different types of objects. Here's an example schema:
Unfortunately, I encountered the following error while attempting to generate TypeScript code:
The workaround suggestion was to use an enum, but this doesn't allow for complex payloads, which I need.
Request
It would be great if the schema could support a
jsonb
type, like so:This way, the
oneOrTwo
field could accept any valid JSON, significantly simplifying the table layout and improving flexibility in handling different object types.The text was updated successfully, but these errors were encountered: