AB#128968-use-user-context-fields#1224
Open
GhaziAlibi wants to merge 3 commits intonextfrom
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for user contextual placeholders (e.g. {{user.country}}) in calculated fields by extending the expression parser and calculated-field aggregation pipeline to resolve values from the logged-in user’s attributes.
Changes:
- Extend calculated field parsing to recognize
user.*operators and return anOperatorAST. - Thread
context.user.attributesinto calculated field pipeline generation and resolve missing attributes to empty strings. - Update resource mutation logic to safely persist direct (non-
calc.*) expressions; add unit tests for the new behavior.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Adds Jest/Node types for TS compilation. |
| src/utils/schema/resolvers/Query/all.ts | Passes user attributes into calculated-field pipeline builder. |
| src/utils/files/resourceExporter.ts | Passes user attributes into calculated-field pipelines used for exports. |
| src/utils/context/getContextData.ts | Passes user attributes into calculated-field pipelines used for context evaluation. |
| src/utils/aggregation/expressionFromString.ts | Adds parsing support for {{user.*}} and returns an Operator instead of Operation. |
| src/utils/aggregation/buildCalculatedFieldPipeline.ts | Resolves user operators during pipeline generation; supports direct (non-expression) placeholders. |
| src/schema/query/recordsAggregation.query.ts | Passes user attributes into calculated-field pipeline builder for aggregations. |
| src/schema/mutation/editResource.mutation.ts | Adjusts calculated field type inference to handle non-expression operators safely. |
| src/const/calculatedFields.ts | Extends operator types to include user and allow null constants. |
| config/who-dev.js | Changes dev config for Microsoft Graph usage. |
| tests/unit-tests/utils/aggregation/buildCalculatedFieldPipeline.spec.ts | Adds unit tests for direct user placeholders and missing-attribute fallback. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds support for user contextual fields in calculated fields.
This updates the calculated field parser and aggregation pipeline to accept expressions such as {{user.country}} and resolve them from the logged-in user's attributes. Missing user attribute values now resolve to empty strings. The resource mutation logic was also updated so these direct user expressions can be saved safely as calculated fields.
Useful links
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Screenshots
Checklist:
( * == Mandatory )
More explanation
https://www.loom.com/share/05a716d61b9744faaf51fb304c21d1e5?sid=f87cf896-582a-4f76-93ae-8ceed801b145