Merged
Conversation
Fragments are now generic types with a __id property. At glance it seems like a phantom type, but it's an actual property generated by the content proxy that works with deepkit for runtime validation of the fragment type.
|
Awesome - is there an easy way to test a local rails app against this checked out branch locally? 👀 |
Collaborator
Author
|
Kind of. I've build it locally and use Then you have to ensure you're running a single copy of react Now you should be able to go back to your rails app to do something like: |
Collaborator
Author
|
@AlanFoster Note that you'd still have to follow the instructions in this pr to add the deepkit plugin. I still need to update |
Collaborator
Author
|
@AlanFoster I released |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for runtime types using deepkit and resolves #168. What makes this approach more useful is that it's a typescript first approach to writing types and we still get the developer happiness of what makes rails rails.
In ruby land, we often come across tools (things like graphql, typelizer, etc) that encourage
This flow always felt a bit off to me, for a few reasons:
Bottom line. These tools tries it best to ensure that the backend and frontend are "in-sync", but it fails to improve the rails experience while also making the typescript experience worse.
Contracts
There has to be a better alternative. Let's let rails be rails, but reinforce the shape and values through runtime contracts on reception (during dev) by your frontend instead of end-to-end typing. Without compromising the rails and typescript experience.
Runtime types
This PR brings in deepkit as an optional dependency. There are no changes to the way folks work already in Superglue. Just pass a type to useContent as you normally would
And you get runtime types for free:
Almost, free. We do have to add
and add another plugin to your build tool of choice, e.g. esbuild:
But the tradeoff seems good for such an amazing DX.
A nice side effect: You can use any json builder library with Superglue and still get this experience.