Edit in GitHubLog an issue

Transforms

While handlers let you bring outside sources into API Mesh for Adobe Developer App Builder, transforms allow you to modify the schema to control the contents of your GraphQL requests and responses.

API Mesh currently supports the following transforms:

Additionally, the following transforms are available but are not fully supported by API Mesh at this time. This means that your mesh will accept the transform, but we have not tested the transform thoroughly and you may encounter errors. Additionally, certain transform options may be disabled due to security concerns.

Other transforms are not supported.

Prefix

The Prefix transform allows you to add prefixes to existing types and root operations. prefix is similar to rename in that it allows you to modify names to avoid conflicts, simplify complicated names, and change the appearance of your query. In contrast with rename, prefix is simpler and only allows you to append a prefix to the existing name. In the example below, we differentiate our sources by adding an "AEM" prefix to the AEM source and a "Venia" prefix to the PWA source.

Copied to your clipboard
{
"meshConfig": {
"sources": [
{
"name": "AEM",
"handler": {
"graphql": {
"endpoint": "https://example1.com/graphql"
}
},
"transforms": [
{
"prefix": {
"includeRootOperations": true,
"value": "AEM_"
}
}
]
},
{
"name": "PWA",
"handler": {
"graphql": {
"endpoint": "https://example2.com/graphql"
}
},
"transforms": [
{
"prefix": {
"includeRootOperations": true,
"value": "Venia_"
}
}
]
}
]
},
}

Rename

Rename transforms allow you to rename a GraphQL field, type, or field argument. Renaming allows you to avoid conflicting names, simplify complicated names, and make queries look more like mutations. In the example below, we rename a long API field name from integrationCustomerTokenServiceV1CreateCustomerAccessTokenPost to the shorter CreateCustomerToken.

rename elements can contain arrays of individual renaming operations, defined in separate renames objects. Each of these objects must define the from and to values.

Copied to your clipboard
{
"meshConfig": {
"sources": [
{
"name": "CommerceREST",
"handler": {
"openapi": {
"source": "https://www.example.com/rest/all/schema?services=all"
}
},
"transforms": [
{
"rename": {
"renames": [
{
"from": {
"type": "Mutation",
"field": "integrationCustomerTokenServiceV1CreateCustomerAccessTokenPost"
},
"to": {
"type": "Mutation",
"field": "CreateCustomerToken"
}
}
]
}
}
]
}
]
},
}

Filter schema

The Filter Schema transform allows you to specify which schema elements to include or exclude in your mesh. You can include or exclude entire queries and mutations, or place restrictions on which types can appear in your calls.

For example, you might want to exclude deprecated queries, mutations, and types from your schema so that your integration is not affected when these entities are removed. In the example below, the deprecated Adobe Commerce category and customerOrders queries are filtered out of the PWA handler.

Copied to your clipboard
{
"meshConfig": {
"sources": [
{
"name": "AEM",
"handler": {
"graphql": {
"endpoint": "https://example1.com/graphql"
}
}
},
{
"name": "PWA",
"handler": {
"graphql": {
"endpoint": "https://example2.com/graphql"
}
},
"transforms": [
{
"filterSchema": {
"filters": [
"Query.!category",
"Query.!customerOrders"
]
}
}
]
}
]
},
}

Replace Field

Replace field transforms allow you to replace the configuration properties of one field with another, which allows you to hoist field values from a subfield to its parent. Use this transform to clean up redundant queries or replace field types. In the example below, the parent field is being replaced by the child field.

Copied to your clipboard
{
"meshConfig": {
"sources": [
{
"name": "PWA",
"handler": {
"graphql": {
"endpoint": "https://example2.com/graphql"
}
},
"transforms": [
{
"replaceField": {
"replacements": [
{
"from": {
"type": "Query",
"field": "parent"
},
"to": {
"type": "<your_API_Response>",
"field": "child"
},
"scope": "hoistvalue"
}
]
}
}
]
}
]
}
}

Type Merging

Type Merging allows you to combine multiple sources by merging a type from each source. For example, you could combine responses from two different APIs on a single field, provided you rename the fields you want to stitch to the same name. For more information, see this example.

Naming Convention

Naming Convention transforms allow you to apply casing and other conventions to your response. In the example below, enumValues fields are converted to uppercase, while fieldNames are converted to camel case to enforce consistency.

Copied to your clipboard
{
"meshConfig": {
"sources": [
{
"name": "PWA",
"handler": {
"graphql": {
"endpoint": "https://example2.com/graphql"
}
},
"transforms": [
{
"namingConvention": {
"enumValues": "upperCase",
"fieldNames": "camelCase"
}
}
]
}
]
},
}
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.