-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Hi,
Scenario
Org Explorer is an Apollo graphql people experience (aka.ms/orgexplorer) where my team integrated People Highlights (ref on scenario here). Our integration package is implementing the nova data interface.
Background info
Today highlights are integrated in the host app (OrgX) root query. OrgX is a NON-nova host app. Highlights type is embedded inside OrgX root query making the implementation of useLazyLoadQuery difficult. so far we opted for implementing the following methods, while querying happens inside the host app and then it's passed down as props:
useMutation- this works well because highlights are not embedded in the orgx root mutation (it's decoupled)useFragment- we are relying on the default implementation where data passed via props is mirrored.
Challenge
Since data is passed down via props, we can't ensure proper usage of useFragment unless we extract from the Fragment$key the data and forcefully cast it to a ref.
const highlightRef = props.personaHighlightFragment[" $data"] as unknown as {
readonly " $fragmentRefs": FragmentRefs<"HighlightsFragment">;
};where personaHighlightFragment is a Nova fragment constructed this way (on the host app)
// Convert from Apollo fragment to Nova(Relay) fragment
const personaHighlightFragment: NovaHighlightsFragment$key = {
" $fragmentRefs": { HighlightsFragment: true },
" $data": personaHighlight as NovaHighlightsFragment,
};Ask: Enable nova to handle such object transformations when data is not fetched via useLazyLoadQuery but rather passed via props.