building-envelope-data / metabase

Metabase of the product data network buildingenvelopedata.org
2 stars 3 forks source link

Add Custom Scalar Specification URLs #157

Open simon-wacker opened 1 year ago

simon-wacker commented 1 year ago

Specification URLs can be added to custom scalars with the @specifiedBy directive. I tried to add those to our custom scalars Url and Uuid in https://github.com/building-envelope-data/metabase/commit/4b41cf9573521f9cb60b9c117cc057ac047c7af7#diff-261824ef50a05a253c139e223362d953fa719e183552a6f7a95b1202c59f2444R87-R91 by adding types MyUuidType and MyUrlType and using those instead of HotChocolate's default UuidType and UrlType scalars. This fails at the moment because if we use the My... types, then the resulting schema contains four scalars URL, Url, UUID, and Uuid and the upper-case variant is used for fields of type Uri and Guid. I tried adding .BindRuntimeType<Guid, MyUuidType>() and changing the binding behavior of the My... types to implicit without success. A solution may be to set options.DefaultBindingBehavior = BindingBehavior.Implicit to Explicit; with the option, the schema cannot be generated though as is and I don't know why (the resulting errors are somewhat crypted; I suppose it has to do with the order in which types are added).

For details on @specifiedBy see Custom Scalar Specification URLs.