ICustomerManagementGET Apex Interface
The ICustomerManagementGET Apex interface provides extensibility for TMF629 GET operations through Apex pre- and post-hooks and GraphQL query customization. Implementations can validate incoming requests, modify query structures, and refine the response to support business-specific retrieval rules while maintaining TMF-compliant behavior.
This interface supports the following hooks.
The configureDefaultValidations hook is not used for the Customer Management API. If implemented, the method may be invoked, but its return values are ignored.
This table lists common use cases and the hooks required for the GET operation.
| Use Case | Hook(s) | Description | Example Scenarios | Benefit |
|---|---|---|---|---|
| Role-Based Data Filtering | applyCustomValidations, handlePostOperation | Enforces access rules by validating user permissions before execution and filtering sensitive data after retrieval. Supports role-based visibility at field and record levels. | • Restrict access to VIP or high-value customer profiles• Hide sensitive fields (e.g., credit score) for frontline agents• Enforce region-based access boundaries | Strengthens data governance and ensures secure, compliant access to customer data |
| Custom Field Enrichment | handlePostOperation | Adds calculated or derived fields to API responses without changing the base TMF schema, allowing customers to extend or modify as needed. Enables enrichment using internal business rules or external systems. | • Add customer health score• Flag “preferred customer” status• Include aggregated financial or usage insights | Delivers richer, more contextual responses while preserving TMF schema integrity |
| Dynamic Query Customization | customiseGraphQLQuery | Modifies GraphQL queries dynamically based on client or request context by adding fields, filters, or transformations. | • Mobile app requests only essential fields• Portal requires additional entitlement or hierarchy fields• Apply filters automatically for partner channels | Supports diverse client requirements using a single API and reduces need for API versioning |
| Business Rule Validation | applyCustomValidations | Applies business and eligibility rules before processing requests, stopping invalid operations early in the lifecycle. | • Ensure customer is “active” before retrieving services• Reject unauthorized or unverified channel requests• Enforce lifecycle or dependency checks | Provides strong business consistency and reduces downstream errors by blocking invalid requests early |
This hook transforms the request context before processing any operation. It is invoked early in the request lifecycle, allowing implementers to adjust the context for subsequent extensibility hooks.
Map<String, Object> transformRequest(Map<String, Object> context)
This hook validates custom business logic before retrieving customer record. If validation fails, it rejects the request and returns an error response.
The handler processes return values as follows.
Success:
- Return a map with validationStatus set to “pass” (case-insensitive).
- The API request continues normally.
- Other fields in the map are logged but not used.
Failure:
- Return a map with validationStatus set to “fail” (case-insensitive).
- The API request is terminated immediately.
- Raise a ValidationException containing
- message: value from validationMessage key (or “Validation failed” by default)
- details: value from validationDetails key (optional)
- The client receives an HTTP 400 error response.
Map<String, Object> applyCustomValidations(Map<String, Object> context)
This hook modifies the GraphQL query before execution to add fields, filters, or transformations. Returns a map with a spec key containing a list of QueryTransformationNode objects.
Map<String, Object> customiseGraphQLQuery(Map<String, Object> graphQLAsMap, Map<String, Object> context)
This hook post-processes and transforms the API response after data retrieval.
To include additional fields in the final GET API response using the handlePostOperation hook, set payloadOverwritten to true and provide the modified response through updatedPayload.
Map<String, Object> handlePostOperation(Map<String, Object> graphQLQueryResultAsMap, Map<String, Object> constructedTMFResponse, Map<String, Object> context)
Here’s a complete sample Apex implementation using all supported hooks.
Query transformations provide the ability to enhance GraphQL queries by adding fields, applying filters, or modifying the sort order, while preserving the original query definition.
customiseGraphQLQuery returns a map with a top-level nodes key. The value is a list of transformation nodes. Any other top-level key, such as spec, is ignored and the query isn’t changed.
Each node has these properties.
| Property | Required | Description |
|---|---|---|
path | Yes | Alias path of the query field to change. For the Customer Management API, the primary Account query alias is customerAccount. Use dots for nested fields, such as customerAccount.myContacts. Don’t start the path with uiapi. |
addFields | No | List of fields to add to the selection at path. Custom fields, such as Region__c, are supported. |
addFilters | No | Object with clearExistingFilters (boolean) and filterGraphQlSnippet (string). |
orderBy | No | Object with clearExistingOrderBy (boolean) and orderGraphQlSnippet (string). |
insertGraphQlSnippet | No | GraphQL snippet to insert into the query. |
The path is the alias of the field in the GraphQL query, not a schema path. If a transformation has no effect, check that the alias matches the query.
The API builds a filter from the URL query parameters, for example ?name=Acme. The clearExistingFilters property controls how your filter combines with it.
| Value | Behavior |
|---|---|
true | Replaces all existing filters, including filters built from URL query parameters, with your filterGraphQlSnippet. |
false | Keeps the existing filters and combines them with yours using and: [ ... ]. |
If you build the filter yourself in Apex from the URL query parameters, set clearExistingFilters to true. Otherwise the same condition is applied twice.
This sample returns only the Accounts whose Industry is Technology. It uses clearExistingFilters set to false because it doesn’t read the URL query parameters. If your Apex builds the filter from them, switch to true.
A portal can authenticate a user as a Contact and then need the Accounts that Contact belongs to. Use one of these approaches.
Option 1: Filter on a Contact field on Account. If your Account object has a field that references the Contact, such as a custom lookup, filter on it in customiseGraphQLQuery. Primary_Contact__c is a sample name. Replace it with your own field.
Option 2: Look up the Accounts in handlePostOperation. If the relationship isn’t a field on Account, such as the relationship through AccountContactRelation, query the related Accounts in the handlePostOperation hook and return them with payloadOverwritten set to true and the result in updatedPayload. See handlePostOperation.
| Symptom | Likely cause and fix |
|---|---|
| The query isn’t changed. | The returned map doesn’t use the top-level nodes key. Return {'nodes' => ...}. |
| A node has no effect. | The path doesn’t match a query alias, or it starts with uiapi. Use the alias, such as customerAccount. |
| A field doesn’t appear in the response. | Check that path is correct and that the field exists on the object and is visible to the user. |
| A filter isn’t applied, or it’s applied twice. | Check the snippet syntax and field names. Check clearExistingFilters: true replaces URL filters, false adds to them. |
Fields added in handlePostOperation don’t appear. | Set payloadOverwritten to true and return the modified response in updatedPayload. |
| The extension isn’t invoked. | Use a current API version, such as v67.0. Older version URLs, such as v60.0, don’t invoke the extension. |
Original Query (GraphQL):
Transformation Instructions (JSON):
Result (GraphQL):
Original Query (GraphQL):
Transformation Instructions (JSON):
Result (GraphQL):
Original Query (GraphQL):
Transformation Instructions (JSON):
Result (GraphQL):
Original Query (GraphQL):
Transformation Instructions (JSON):
Result (GraphQL):