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.

Transforms are specified as a list of objects, and they are executed in order. You can apply them to a specific handler or the entire mesh.

Transforms available

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 could encounter errors. Additionally, certain transform options may be disabled due to security concerns.

Other transforms are not supported.

Handler-level transforms and mesh-level transforms

When adding a transform to your mesh, you can choose to have the transform affect a single source (handler) or the entire mesh. The following examples use prefix transforms, which are the preferred method of avoiding conflicting object names across multiple schemas.

The following example uses the prefix transform to prefix "REST_" to all queries and mutations from the REST source.

Copied to your clipboard
{
"meshConfig": {
"sources": [
{
"name": "REST",
"handler": {
"openapi": {
"source": "https://venia.magento.com/rest/all/schema"
}
},
"transforms": [
{
"prefix": {
"includeRootOperations": true,
"value": "REST_"
}
}
]
},
{
"name": "GraphQL",
"handler": {
"graphql": {
"endpoint": "https://venia.magento.com/graphql"
}
}
}
]
}
}

Conversely, the following example uses prefix to apply the "ADOBE_" prefix to every source in the mesh.

Copied to your clipboard
{
"meshConfig": {
"sources": [
{
"name": "REST",
"handler": {
"openapi": {
"source": "https://venia.magento.com/rest/all/schema"
}
}
},
{
"name": "GraphQL",
"handler": {
"graphql": {
"endpoint": "https://venia.magento.com/graphql"
}
}
}
],
"transforms": [
{
"prefix": {
"includeRootOperations": true,
"value": "ADOBE_"
}
}
]
}
}

Working with transforms

When working with transforms, consider the following:

  • Transforms are processed in order
  • Having many transforms in a mesh should not impact performance
  • Transforms at the mesh level will impact additionalResolvers

Transform order

The following transform will fail. The mesh will not find the Customer type to filter by, because the namingConvetion transform converted it to lowercase (customer):

Copied to your clipboard
...
"transforms": [
{
"namingConvention": {
"typeNames": "lowerCase",
}
},
{
"filterSchema": [
"Query.Customer"
]
}
]
...

Transforms and additionalResolvers

Use caution when applying mesh-level transforms; modifying the schema at this level will impact any additionalResolvers. For example, if you use filterSchema to remove a type, an additionalResolver will not be able to access that type.

Versions

The following table specifies the GraphQL Mesh versions of each transform supported by API Mesh for Adobe Developer App Builder:

TransformVersion
0.4.21
0.11.14
0.15.23
0.13.22
0.12.22
0.14.22
0.5.20
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.