Override intern graph calls in flipper-ui-core

Summary:
> "Hi, kids, do you like violence?"

Alrighty, in flipper-frontend-core we have the **base** implmenetation of flipperLib (the thing exposed to the plugins). This base implementation is never used directly by the plugins, rather it is shared code used by the  real consumers - flipper-ui-core (regular Flipper with UI) and flipper-server-companion (the thing that allows hosting plugins on the server).
These real consumers actually run the plugins and expose flipperLib to the plugins.
In flipper-ui-core we have a more sophisticated logic of calling the intern graph - we check for VPN connection and authn. Therefore, to expose the same way of handling intern graph requests we **override** intern graph calls provided by flipper-frontend-core.
*Ideally*, we should move checking for VPN connection and authn to flipper-frontend-core, but currently it is a lot of effort for very little gains:
1. flipper-frontend-core does not have a notion of a user
2. Even if we move the authn-related logic there the only real consumer of that effort if flipper-server-companion that is used only by UIQR (which in its turn is barely used in the headless mode and do not require authn-related logic).

Thus, we just override intern graph request on the flipper-ui-core side since it is the simplest and the most impactful thing to do at the moment.

Reviewed By: LukeDefeo

Differential Revision: D49494922

fbshipit-source-id: 6f1d521af7ca5bd50549b7bc328d6b8fcab98389
This commit is contained in:
Andrey Goncharov
2023-09-21 03:15:10 -07:00
committed by Facebook GitHub Bot
parent 550b49e690
commit f4a286d9c7

View File

@@ -17,7 +17,12 @@ import {addNotification} from '../../reducers/notifications';
import {deconstructPluginKey} from 'flipper-common'; import {deconstructPluginKey} from 'flipper-common';
import {RenderHost} from 'flipper-frontend-core'; import {RenderHost} from 'flipper-frontend-core';
import {setMenuEntries} from '../../reducers/connections'; import {setMenuEntries} from '../../reducers/connections';
import {currentUser, isConnected} from '../../fb-stubs/user'; import {
currentUser,
internGraphGETAPIRequest,
internGraphPOSTAPIRequest,
isConnected,
} from '../../fb-stubs/user';
export function initializeFlipperLibImplementation( export function initializeFlipperLibImplementation(
renderHost: RenderHost, renderHost: RenderHost,
@@ -29,6 +34,8 @@ export function initializeFlipperLibImplementation(
...base, ...base,
intern: { intern: {
...base.intern, ...base.intern,
graphGet: internGraphGETAPIRequest,
graphPost: internGraphPOSTAPIRequest,
currentUser, currentUser,
isConnected, isConnected,
}, },