Who to use resolver

i write the confluence manifest but when i write the resource i only use the resources i dont know how resolver works
this is my manifest

modules:

  confluence:contextMenu:

    - key: forge-manifest-contextmenu-hello-world

      title: forge-manifest-contextMenuss

      resource: main

      resolver:

        function: resolver

      viewportSize: small

  function:

    - key: resolver

      handler: index.handler

resources:

  - key: main

    path: static/hello-world/build

app:

  id: ari:cloud:aaa

  name: forge-manifest-contextMenusss

and the index.js

import Resolver from '@forge/resolver';

const resolver = new Resolver();

resolver.define('getText', (req) => {
  console.log(req);

  return 'Hello, world!';
});

export const handler = resolver.getDefinitions();

who can tell me what is Resolver and who it works
thank you~

1 Like

Hi @111112,

Resolvers can be used by your Custom UI frontend to communicate with the “forge backend”. In your example, you have defined a getText resolver, so in your Custom UI frontend you could call it like this:

import { invoke } from "@forge/bridge";

invoke("getText").then((returnedData) =>
  console.log(returnedData); // prints "Hello, world!"
);

This can be useful if you want to access the forge storage API for example. Please also refer to the official documentation on Custom UI and Resolvers for more details.

Hope this helps!

Cheers,
Sven