Real-time Updates With Mercure

API Platform Admin support real-time updates by using the Mercure protocol.

API プラットフォーム管理者は、Mercure プロトコルを使用してリアルタイムの更新をサポートします。

Updates are received by using the useMercureSubscription hook in the ListGuesser, ShowGuesser and EditGuesser components.

更新は、ListGuesser、ShowGuesser、および EditGuesser コンポーネントで useMercureSubscription フックを使用して受信されます。

To enable Mercure server-side, see the related documentation.

Mercure サーバー側を有効にするには、関連ドキュメントを参照してください。

Once enabled, API Platform Admin for Hydra will automatically detect that Mercure is enabled and will discover the Mercure hub URL by itself.

有効にすると、API Platform Admin for Hydra は Mercure が有効になっていることを自動的に検出し、Mercure ハブ URL を自動的に検出します。

Advanced Configuration

If you want to customize the default Mercure configuration, you can either do it with a prop in the <HydraAdmin> or <OpenApiAdmin> component:

デフォルトの Mercure 設定をカスタマイズしたい場合は、theorcomponent の prop を使用して行うことができます。

import { OpenApiAdmin } from "@api-platform/admin";

export default () => (
  <OpenApiAdmin
    entrypoint="https://demo.api-platform.com"
    docEntrypoint="https://demo.api-platform.com/docs.json"
    mercure={{ hub: "https://mercure.rocks/hub" }}
  />
);

Or in the data provider factory:

または、データ プロバイダー ファクトリで次のようにします。

import { hydraDataProvider, fetchHydra } from "@api-platform/admin";
import { parseHydraDocumentation } from "@api-platform/api-doc-parser";

const dataProvider = baseHydraDataProvider({
  entrypoint,
  httpClient: fetchHydra,
  apiDocumentationParser: parseHydraDocumentation,
  mercure: { hub: "https://mercure.rocks/hub" },
});

The mercure object can take the following properties: - hub: the URL to your Mercure hub (default value: null ; when null it will be discovered by using API responses) - jwt: a subscriber JWT to access your Mercure hub (default value: null) - topicUrl: the topic URL of your resources (default value: entrypoint)

mercure オブジェクトは次のプロパティを取ることができます:- hub: Mercure ハブへの URL (デフォルト値: null ; null の場合、API 応答を使用して検出されます)- jwt: Mercure ハブにアクセスするためのサブスクライバー JWT (デフォルト値: null)- topicUrl: リソースのトピック URL (デフォルト値: entrypoint)