Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional global variables for Rhai scripts #6041

Open
dupham-indeed opened this issue Sep 23, 2024 · 0 comments
Open

Additional global variables for Rhai scripts #6041

dupham-indeed opened this issue Sep 23, 2024 · 0 comments

Comments

@dupham-indeed
Copy link

Is your feature request related to a problem? Please describe.

Currently, Rhai's support for global variables is limited to only things that are maintained by Router.* (https://www.apollographql.com/docs/router/customizations/rhai/#global-variables) without the option to store additional ones

Describe the solution you'd like

During a Rhai script callback functions' execution, our application would like to create and maintain additional values as global variables that can be later used by other router request lifecycles

fn subgraph_service(service, subgraph){
    let v = Router.EXTRA_VARIABLE;
    let f = |request| {
        print(v);
    };
    service.map_request(f);
    Router.EXTRA_VARIABLE++;
}

Describe alternatives you've considered

A coprocessor can achieve this but we would like to use Rhai to improve performance by minimizing communication costs between the coprocessor and the router

Additional context

Add any other context or screenshots about the feature request here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant