replaceField transform
The replaceField transform is deprecated. If you attempt to create an edge mesh with the replaceField transform, your edge mesh will not progress past the provisioning status. Alternatively, you can use the following additonalResolvers method.
Replacing fields with additionalResolvers
Previously, the replaceField transform allowed you to replace the configuration properties of one field with another, hoisting field values from a subfield to its parent. This transform allowed you to clean up redundant queries or replace field types.
Since the replaceField transform is deprecated, you can achieve the same functionality by using additionalResolvers in your mesh configuration. The additionalResolvers property allows you to add custom resolvers to your mesh. These resolvers can replace fields, hoist values, or perform other custom logic.
Custom resolvers can hoist and replace existing fields as long as the field types are the same. If the field types are different, you can extend the type to include a new field and hide the original field using a filterSchema transform.
The following example hoists the Adobe Commerce name field from the ProductInterface to the label field of ProductImage by adding the replace.js resolver to the mesh configuration.
mesh.jsonreplace.jsCopied to your clipboard{"meshConfig": {"sources": [{"name": "AdobeCommerce","handler": {"graphql": {"endpoint": "https://venia.magento.com/graphql"}},}]"additionalResolvers": ["./replace.js"]}}
Copied to your clipboardmodule.exports = {resolvers: {SimpleProduct: {name: {selectionSet: '{ name image { label } }',resolve: (root) => {return root.image.label;}}}}}