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
I'm new to cockpit and I've encountered a strange behaviour regarding "optional fields".
Currently i have a model in Cockpit, which involves Fields that might be empty. The API then responds with an empty string, regardles of the field type (In my case the fields are of the type set, the fields object in the response contains the correct definitions, but the actual items contain an empty string).
These strange empty Strings confuse the schema-generation of gatsby and result in an GqlType String for Doors, which in turn isn't queryable correctly.
The empty strings are returned for all kind of fields. In my model I also have the types image, markdown and repeater that behave the same way.
I'm wondering, if theres a way to tell Cockpit to return null instead of empty strings or to tell the plugin to ignore those empty strings.
Cheers
Flo
--- edit ---
Looking through the sources of the plugin i came across the createCollectionItem method, which checks if the provided field is an array with values or null before transforming it.
This leads me to the conclusion that there might a way to tell cockpit to return more appropiate values for "empty" fields.
If there's no way to configure the return value in cockpit I'd be happy to create a PR which extends this condition to include a check for empty strings (or provide a extension point to inject some middleware into this transformation)
The text was updated successfully, but these errors were encountered:
Hi @aequi42, you're right, it would be feasible with a custom Cockpit plugin, but I would prefer that this project remains compatible with any vanilla Cockpit setups as long as there is no other means to deal with a problem. So, for now, you could extend the condition :)
Hi,
I'm new to cockpit and I've encountered a strange behaviour regarding "optional fields".
Currently i have a model in Cockpit, which involves Fields that might be empty. The API then responds with an empty string, regardles of the field type (In my case the fields are of the type
set
, thefields
object in the response contains the correct definitions, but the actual items contain an empty string).These strange empty Strings confuse the schema-generation of gatsby and result in an GqlType
String
forDoors
, which in turn isn't queryable correctly.The empty strings are returned for all kind of fields. In my model I also have the types
image
,markdown
andrepeater
that behave the same way.I'm wondering, if theres a way to tell Cockpit to return
null
instead of empty strings or to tell the plugin to ignore those empty strings.Cheers
Flo
--- edit ---
Looking through the sources of the plugin i came across the
createCollectionItem
method, which checks if the provided field is an array with values ornull
before transforming it.This leads me to the conclusion that there might a way to tell cockpit to return more appropiate values for "empty" fields.
If there's no way to configure the return value in cockpit I'd be happy to create a PR which extends this condition to include a check for empty strings (or provide a extension point to inject some middleware into this transformation)
The text was updated successfully, but these errors were encountered: