⚠️
This is the documentation for the old GraphQL Mesh version v0. We recommend upgrading to the latest GraphQL Mesh version v1.
Migrate to GraphQL Mesh v1
Migrate to GraphQL Mesh v1
Encapsulate Transform
The encapsulate
transform allows 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
:
type Query {
something: String
}
type Mutation {
doSomething: String
}
The encapsulate
transform will change your schema to this:
type Query {
mySchema: mySchemaQuery!
}
type Mutation {
mySchema: mySchemaMutation!
}
type mySchemaQuery {
something: String
}
type mySchemaMutation {
doSomething: String
}
This transformer 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.
To get started with this transform, install it:
npm i @graphql-mesh/transform-encapsulate
How to use?
.meshrc.yaml
transforms:
- encapsulate:
applyTo:
query: true
mutation: false
subscription: false
Config API Reference
name
(type:String
) - Optional, name to use for grouping under the root types. If not specific, the API name is used.applyTo
(type:Object
) - Allow you to choose which root operations you would like to apply. By default, it’s applied to all root types.:query
(type:Boolean
)mutation
(type:Boolean
)subscription
(type:Boolean
)