Closed andrewmcgivery closed 8 months ago
Unfortunately, I'm fairly sure that this is the expected behaviour in Rhai
, as documented here: https://rhai.rs/book/ref/fn-ptr.html
I may be mis-interpreting the documentation, so I'll follow up with the Rhai
community and will update this ticket when I have a response.
In conversation with the lead Rhai
developer, this definitely is expected behaviour and there's no downside to importing the module in the function directly as the workaround suggests.
This is essentially a limitation in Rhai
itself and so I think we should close this issue here.
closing this issue for now, feel free to reopen if there's new approachs available in rhai that could help here
Describe the bug We have a client trying to access the name of the subgraph within a rhai script from a map_request function. As far as I can tell, the name is available in the subgraph_service function but it is not exposed via request.subgraph once map_request is called. So, he is trying to do a call with curry to inject it.
However, when he does this, an imported module is no longer in scope that should be.
To Reproduce The following code reproduces the issue:
The (hacky) workaround that does seem to work:
In the broken example,
subgraph_module
should be in scope... but it isn't for some reason. In the second example, we are moving the import into the function and it does work.Expected behavior Imported modules should be in scope.