Add @__RelayTypegenTypeOverride to use in CustomTransform to replace TS/JS type #4766
+1,137
−3
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 PR introduces and internal directive (
@__RelayTypegenTypeOverride
) to use in a TypgenCustomTransform
(basic example)It allows the
CustomTransform
to specify a type, path and generic arguments to be used in the JS/TS type instead of the default type.I attempted to solve this with just the
CustomTransform
but didn't manage. I think the current approach should be generic enough for others to benefit from.Example use case:
I want to specify localized strings through GraphQL and serve them using LiveResolvers. Some of these will have placeholders
Based on the above I want the compiler to generate a more strict type that I can use to check if this required placeholders for the string are also provided.
Using this custom type I can make sure we "inject" the placeholder into the string by having a strongly typed function that ensures the correct placeholders are passed for each of the
LocalizedString
s.