Custom UI Resolver
A Resolver allows you to define backend functions (functions running in the runtime) for your custom UI application. The frontend of the custom UI can call the functions defined by the resolver through the invoke API.
Usage
Configuremanifest.yml:
modules:
workspacePage:
- key: workspace-page
title: workspace-title
resource: main
loadType: Micro
resolver:
function: resolver-function
function:
- key: resolver-function
handler: index.handler
resources:
- key: main
path: dist
The function in resolver points to the key in the function module.
caution
Each module can only correspond to one resolver function, but a resolver function can define multiple methods.
Definition of resolver methods
import { Resolver } from '@giteeteam/apps-api';
const resolver = new Resolver();
resolver.define("method-key", ({ payload }) => {
// payload is the parameter passed by the invoke below
const { example } = payload
console.log(example)
let result;
// your code
return result;
})
resolver.define("method-key-2", ({ payload }) => {
// payload is the parameter passed by the invoke below
const { example } = payload
console.log(example)
let result;
// your code
return result;
})
export const handler = resolver.getDefinitions();
Use invoke API to call methods of resolver
Refer to invoke for details.
In the frontend code of Custom UI, import @giteeteam/plugin-sdk
import { invoke } from '@giteeteam/plugin-sdk';
const Demo = () => {
useEffect(() => {
const payload = {
example: 'hello'
}
const result = await invoke("method-key", payload); // payload is the execution parameter
console.log(result) // returned data
},[])
return <div></div>
}