Merge pull request #6399 from backstage/freben/fetch-api

Add `fetchApiRef` which implements fetch, plus Backstage token header when available
This commit is contained in:
Fredrik Adelöw
2021-12-16 11:30:37 +01:00
committed by GitHub
25 changed files with 755 additions and 19 deletions
+1 -1
View File
@@ -66,7 +66,7 @@ export type BackstageOverrides = Overrides & {
// Warning: (ae-missing-release-tag) "CatalogClientWrapper" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
// @public @deprecated
export class CatalogClientWrapper implements CatalogApi {
constructor(options: { client: CatalogClient; identityApi: IdentityApi });
// (undocumented)
@@ -30,6 +30,13 @@ import { IdentityApi } from '@backstage/core-plugin-api';
/**
* CatalogClient wrapper that injects identity token for all requests
*
* @deprecated The default catalog client now uses the `fetchApiRef`
* implementation, which in turn by default issues tokens just the same as this
* class used to assist in doing. If you use a custom `fetchApiRef`
* implementation that does NOT issue tokens, or use a custom `catalogApiRef`
* implementation which does not use the default `fetchApiRef`, you can wrap
* your catalog API in this class to get back the old behavior.
*/
export class CatalogClientWrapper implements CatalogApi {
private readonly identityApi: IdentityApi;
+7 -9
View File
@@ -22,7 +22,6 @@ import {
entityRouteRef,
starredEntitiesApiRef,
} from '@backstage/plugin-catalog-react';
import { CatalogClientWrapper } from './CatalogClientWrapper';
import { createComponentRouteRef, viewTechDocRouteRef } from './routes';
import {
createApiFactory,
@@ -30,7 +29,7 @@ import {
createPlugin,
createRoutableExtension,
discoveryApiRef,
identityApiRef,
fetchApiRef,
storageApiRef,
} from '@backstage/core-plugin-api';
@@ -39,14 +38,13 @@ export const catalogPlugin = createPlugin({
apis: [
createApiFactory({
api: catalogApiRef,
deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef },
factory: ({ discoveryApi, identityApi }) =>
new CatalogClientWrapper({
client: new CatalogClient({ discoveryApi }),
identityApi,
}),
deps: {
discoveryApi: discoveryApiRef,
fetchApi: fetchApiRef,
},
factory: ({ discoveryApi, fetchApi }) =>
new CatalogClient({ discoveryApi, fetchApi }),
}),
createApiFactory({
api: starredEntitiesApiRef,
deps: { storageApi: storageApiRef },