encapsulate
transform
The encapsulate
transform allows you to easily encapsulate a specific schema into a single field under the root type.
For instance, if your handler created a schema like this, named mySchema
:
Copied to your clipboardtype Query {something: String}type Mutation {doSomething: String}
The encapsulate
transform will change your schema to this:
Copied to your clipboardtype Query {mySchema: mySchemaQuery!}type Mutation {mySchema: mySchemaMutation!}type mySchemaQuery {something: String}type mySchemaMutation {doSomething: String}
This transform is useful when you have multiple APIs in your Mesh Gateway and you wish to have it wrapped with a name to better understand where each field is coming from.
Usage
The following example encapsulates the Adobe Commerce schema into the AdobeCommerce
field:
Copied to your clipboard{"meshConfig": {"sources": [{"name": "AdobeCommerce","handler": {"graphql": {"endpoint": "https://venia.magento.com/graphql"}},"transforms": [{"encapsulate": {"applyTo": {"query": true,"mutation": false,"subscription": false}}}]}]}}
Config API Reference
name
(type:String
) - (Optional) The name used for grouping under root types- If you do not specify a
name
, the API name will be used.
- If you do not specify a
applyTo
(type:Object
) - The root operations theencapsulate
applies to. Unspecified options default totrue
:query
(type:Boolean
)mutation
(type:Boolean
)subscription
(type:Boolean
)