Closed kipz closed 6 years ago
Looking at your code,
const pe = `/members::ChatId()
[@id='${slackUserId}']/person::Person()
[/preferences::UserPreferences()]?`;
const match =
ctx.pathExpressionEngine.scalar<cortex.ChatTeam, cortex.ChatTeam>(ctx.contextRoot as cortex.ChatTeam, pe);
// tslint:disable-next-line:no-string-literal
return new FlowConfig(match.members[0].person["preferences"]);
It seems to me this code would be more likely to succeed:
const pe = `/members::ChatId()
[@id='${slackUserId}']/person::Person()
[/preferences::UserPreferences()]?`;
const match =
ctx.pathExpressionEngine.scalar<cortex.ChatTeam, cortex.Person>(ctx.contextRoot as cortex.ChatTeam, pe);
// tslint:disable-next-line:no-string-literal
return new FlowConfig(match.preferences);
The matches returned are of the type of the last step in the path expression, Person
in this case. But you say your code works, so the match is the ChatTeam?
As for your actual question, we'll have to look into that.
Doesn't seem to work from Command Handlers in particular:
https://github.com/atomisthq/enrollment-rugs/blob/6bc37a6fa9b4c1bd84163315ab32a305f5028f50/.atomist/handlers/Common.ts#L18
In this example, it's possible to to use the
scalar
result, but for optional matching, this makes things a bit tricky.Everything below
match.root
is undefined, but it should be possible to navigate the graph from this point.