Skip to content

Commit

Permalink
Improve suspense promise displayName
Browse files Browse the repository at this point in the history
Reviewed By: jsdf

Differential Revision: D27270361

fbshipit-source-id: 376c9bf5778cbd36c3a06ac807c3e7e7c1e55374
  • Loading branch information
Juan Tejada authored and facebook-github-bot committed Mar 24, 2021
1 parent 109d4ba commit 47be7d6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/react-relay/relay-hooks/FragmentResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class FragmentResourceImpl {
// to suspend.
const networkPromise = this._getAndSavePromiseForFragmentRequestInFlight(
fragmentIdentifier,
fragmentNode,
fragmentOwner,
);
if (networkPromise != null) {
Expand Down Expand Up @@ -410,6 +411,7 @@ class FragmentResourceImpl {

_getAndSavePromiseForFragmentRequestInFlight(
cacheKey: string,
fragmentNode: ReaderFragment,
fragmentOwner: RequestDescriptor,
): Promise<void> | null {
const environment = this._environment;
Expand All @@ -432,8 +434,14 @@ class FragmentResourceImpl {
});
this._cache.set(cacheKey, promise);

const queryName = fragmentOwner.node.params.name;
const fragmentName = fragmentNode.name;
const promiseDisplayName =
queryName === fragmentName
? `Relay(${queryName})`
: `Relay(${queryName}:${fragmentName})`;
// $FlowExpectedError[prop-missing] Expando to annotate Promises.
promise.displayName = 'Relay(' + fragmentOwner.node.params.name + ')';
promise.displayName = promiseDisplayName;
return promise;
}

Expand Down

0 comments on commit 47be7d6

Please sign in to comment.