*hook on core.pluginsLoaded to ensure that we don't answer until all plugins are loaded
This commit is contained in:
parent
3600fbfdcf
commit
58e95806d0
|
@ -1,8 +1,17 @@
|
|||
import { Plugin, PluginAPI } from "@lumeweb/relay-types";
|
||||
|
||||
let pluginsLoadedResolve: () => void;
|
||||
let pluginsLoadedPromise = new Promise<void>((resolve) => {
|
||||
pluginsLoadedResolve = resolve;
|
||||
});
|
||||
|
||||
const plugin: Plugin = {
|
||||
name: "core",
|
||||
async plugin(api: PluginAPI): Promise<void> {
|
||||
api.once("core.pluginsLoaded", () => {
|
||||
pluginsLoadedResolve();
|
||||
});
|
||||
|
||||
api.registerMethod("ping", {
|
||||
cacheable: false,
|
||||
async handler(): Promise<any> {
|
||||
|
@ -13,6 +22,10 @@ const plugin: Plugin = {
|
|||
api.registerMethod("get_methods", {
|
||||
cacheable: false,
|
||||
async handler(): Promise<any> {
|
||||
await pluginsLoadedPromise;
|
||||
|
||||
console.log("get_methods", api.rpcServer.getMethods());
|
||||
|
||||
return api.rpcServer.getMethods();
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue