-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
46 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { RelayNetworkLayerResponse } from "react-relay-network-modern" | ||
import { SSRCache } from "react-relay-network-modern-ssr/lib/server" | ||
import serialize from "serialize-javascript" | ||
|
||
export const serializeRelayHydrationData = (initialRelayData: SSRCache) => { | ||
initialRelayData.forEach(entry => { | ||
entry.forEach((item: RelayNetworkLayerResponse) => { | ||
// Clean relay data of problematic data structures | ||
delete item._res | ||
}) | ||
}) | ||
|
||
let hydrationData | ||
|
||
try { | ||
hydrationData = serialize(initialRelayData, { | ||
isJSON: true, | ||
}) | ||
} catch (error) { | ||
hydrationData = "{}" | ||
|
||
console.error( | ||
"[system/router/serializeRelayHydrationData] Error serializing data:", | ||
error | ||
) | ||
} | ||
|
||
return serialize(hydrationData || {}, { | ||
isJSON: true, | ||
}) | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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