IProductOrderGET Apex Interface

The IProductOrderGET Apex interface provides extensibility for TMF622 GET operations through Apex pre- and post-hooks and GraphQL query customization. Implementations can validate incoming requests, modify the primary read query, and refine or overwrite the response to support business-specific retrieval rules while maintaining TMF-compliant behavior.

This interface supports the following hooks.

  • transformRequest
  • applyCustomValidations
  • customiseGraphQLQuery
  • handlePostOperation

Note

The configureDefaultValidations hook is not used for Product Order GET. getDefaultValidationSpec() returns {}. If implemented, return the map unchanged.

This table lists common use cases and the hooks required for the GET operation.

Use CaseHook(s)DescriptionExample ScenariosBenefit
Resolve a legacy or alias order idtransformRequestReplace context["id"] with the canonical Order identifier before GraphQL construction.• Map LEGACY-* / PoNumber to Order.Id
• Accept a partner order id and resolve OrderNumber
Fetch the canonical Order without changing the client URL contract
Stash an entitlement flagtransformRequestPut extra keys on the shared context map for later hooks.• isPremiumTenant for validation and post-processingCross-hook coordination without extra round-trips
Register a custom sub-resourcetransformRequest, customiseGraphQLQueryPut customSubResourceMappings on context and inject the matching GraphQL node. Both steps are required.• Serve GET /productOrder/{id}/orderAdjustmentGroupExtend GET with org-specific child resources
Reject the request with a business ruleapplyCustomValidationsOnly GET hook that surfaces an HTTP error. Return top-level validationStatus = "fail".• Cap filter criteria
• Forbid jeopardy-alert fields for non-premium tenants
Stops invalid retrievals before GraphQL
Add a custom field to the Order querycustomiseGraphQLQueryReturn nodes targeting handler aliases (productOrder, productOrder.productOrderItem, …).• Add NegotiatedPrice__c { value } at the root OrderShape the primary read without forking the handler
Filter or sort nested order itemscustomiseGraphQLQueryaddFilters / orderBy on productOrder.productOrderItem. URL sort still wins over Apex orderBy.• Quantity greater than 1
• EffectiveDate DESC
One API supports channel-specific query shape
Overwrite the GET bodyhandlePostOperationGET applies the return when payloadOverwritten is true. Single GET: Map. List GET: recordList or a raw List of maps.• Add customStatusLabel
• Drop Cancelled rows from list GET
Refine or filter the client-visible TMF payload

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.

Mutating context["id"] is written back via updateIdFromContext. If the Apex result throws, the exception is caught and logged as WARNING — the original id is kept and GET continues.

Map<String, Object> transformRequest(Map<String, Object> context)

Caveat. Appending to context["fields"] does not change the primary GraphQL query. This handler hardcodes the query in buildPrimaryGraphQLQuery. Use customiseGraphQLQuery.

This hook validates custom business logic before retrieving a Product Order. 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 any value other than "fail" (case-insensitive), or an empty map.
  • 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 (or “Validation failed” by default)
    • details: value from validationDetails (optional statusCode / errorCode)

Map<String, Object> applyCustomValidations(Map<String, Object> context)

This hook modifies the primary GraphQL read query before execution. GET is the only Product Order verb that builds an initial read query.

Return {"nodes": [ QueryTransformationNode, ... ]}. The graphQLAsMap argument is {"query": "<base query>"} — informational only. There is no supported way to hand back a rewritten query string.

Node shape

path addresses aliases, not Salesforce relationship names. Addressable paths:

Alias pathWhat it addresses
productOrderRoot Order alias in buildPrimaryGraphQLQuery
productOrder.relatedPartyAccountAccount
productOrder.orderDeliveryGroupsOrderDeliveryGroups
productOrder.productOrderItemOrderItems
productOrder.productOrderItem.itemOrderActionOrderAction
productOrder.productOrderItem.itemProductProduct2
productOrder.productOrderItem.itemPricebookEntryPricebookEntry
productOrder.productOrderItem.itemPricebookEntry.itemProductSellingModelProductSellingModel

An unmatched path silently produces no transformation for that node (WARNING log). Auxiliary queries (jeopardy alerts, order-item attributes, relationships, tax lines) run inside executeGraphQL after this hook and cannot be transformed here.

Map<String, Object> customiseGraphQLQuery(Map<String, Object> graphQLAsMap, Map<String, Object> context)

This hook post-processes the API response after GraphQL execution and TMF conversion. Unlike POST, PATCH, and DELETE, GET applies this return value when payloadOverwritten is true.

Parameters

  • graphQLQueryResultAsMap — raw GraphQL {data, errors, extensions}
  • constructedTMFResponse — already-TMF622-shaped output. Single GET: flat map. List GET: {"recordList": [...]}.
  • context — the same map from earlier hooks

Return value processing

  • { "payloadOverwritten": false } (or omit the key) — observe only; output unchanged.
  • { "payloadOverwritten": true, "updatedPayload": ... } — replace the response.
    • Single-entity: updatedPayload must be a Map.
    • List: updatedPayload must contain recordList as a List, or be a raw List of maps.
  • Wrong type logs WARNING and no-ops. The caller receives the original response.

Map<String, Object> handlePostOperation(Map<String, Object> graphQLQueryResultAsMap, Map<String, Object> constructedTMFResponse, Map<String, Object> context)

Query transformations enhance GraphQL queries by adding fields, applying filters, or modifying sort order, while preserving the original query definition.

Note

For Product Order GET, use handler aliases such as productOrder and productOrder.productOrderItem. Do not use Salesforce relationship names or uiapi.query.Order.

Original Query (GraphQL): primary Order selection from buildPrimaryGraphQLQuery.

Transformation Instructions (JSON):

The field is appended as a sibling of the scalar fields on the root Order alias.

Transformation Instructions (JSON):

URL-level sort takes precedence over Apex orderBy. A trailing Id ASC tiebreaker is always appended.