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
Give devs a way to make use of typescript in superglue. Currently building responses using props_template does not support types. To support types, a developer would have to manually create type definitions for their page responses and separately use props_template to generate responses. This two step process is better than nothing, but not as smooth as something like graphql-ruby where types are automatically generated.
Remove or optionally turn off the magic ofmethod_missing and allow PropsTemplate to accept a JSON Schema and dynamically create subclasses of Props::Template that explicitly define setter methods that match a schema's properties.
# Thoughts: `json` would be an instance of a class that explicitly defines# firstName and agejson.firstName"john"json.age18# The below will raise an errorjson.lastName"smith"json.addressdo# Thoughts: `json` would be an instance of a class that explicitly defines# zipCodejson.zipCode"11233"#This will raise an errorjson.firstName"jill"end
We would also have to add a new generator to superglue_rails that adds respective schemas.
Typescript to JSONSchema.
I'm selecting JSON Schema here because it seems like we can allow user to define types in typescript using typebox , generate the schema, and build the ruby objects.
Its the opposite of graphql-ruby. Instead of starting with ruby to generate the types in typescript. I'm suggesting the opposite, write the types in typescript, and generate the setter interface for props_template.
The text was updated successfully, but these errors were encountered:
Give devs a way to make use of typescript in superglue. Currently building responses using
props_template
does not support types. To support types, a developer would have to manually create type definitions for their page responses and separately useprops_template
to generate responses. This two step process is better than nothing, but not as smooth as something like graphql-ruby where types are automatically generated.
How can we do better?
Examples in the wild:
https://github.com/bullet-train-co/jbuilder-schema
https://graphql-ruby.org/
Suggestion:
Remove or optionally turn off the magic of
method_missing
and allow PropsTemplate to accept a JSON Schema and dynamically create subclasses of Props::Template that explicitly define setter methods that match a schema's properties.Assuming we have :
and we somehow pass this to form_props in an initializer, or set it at the controller level:
Then the following will happen in
show.json.props
We would also have to add a new generator to
superglue_rails
that adds respective schemas.Typescript to JSONSchema.
I'm selecting JSON Schema here because it seems like we can allow user to define types in typescript using typebox , generate the schema, and build the ruby objects.
Its the opposite of graphql-ruby. Instead of starting with ruby to generate the types in typescript. I'm suggesting the opposite, write the types in typescript, and generate the setter interface for props_template.
The text was updated successfully, but these errors were encountered: