villebro edited a comment on issue #14709:
URL: https://github.com/apache/superset/issues/14709#issuecomment-844101647
Something quite similar is already being leveraged in a few plugins,
although in a slightly different context. As you may know, it's possible to
fetch results for multiple queries in a single query context in `buildQuery`:
```
queryContext = {
queries: [
queryObject1,
queryObject2,
],
}
```
Now, to be able to add more query objects based on chart interaction you can
call `setDataMask` and pass it a JSON object called `ownState`. Something like
this:
`setDataMask({ ownState: ['node1'] });`
When you do that, `buildQuery` is retriggered, and you are able to access
the `ownState` object in buildQuery like this:
```ts
export default function buildQuery(formData, options) {
const { ownState } = options; // ['node1']
...
}
```
So anything that you've passed to `ownState` can be used to modify or add
queries to the query context.
If you want to take it one step further, you can even reference another
dataset by specifying different `datasource` in the query object than in the
query object. However, this hasn't really been used that much yet (no proper UI
support exists yet), but I believe we have a unit test in the backend testing
that it should work.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]