---
description:
  Improve your GraphQL schema organization with encapsulate transform. Easily encapsulate a specific
  schema into a single field with GraphQL Mesh.
---

# 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`:

```graphql
type Query {
  something: String
}

type Mutation {
  doSomething: String
}
```

The `encapsulate` transform will change your schema to this:

```graphql
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:

```sh npm2yarn
npm i @graphql-mesh/transform-encapsulate
```

## How to use?

```yaml filename=".meshrc.yaml"
transforms:
  - encapsulate:
      applyTo:
        query: true
        mutation: false
        subscription: false
```

## Config API Reference

import API from '../../../generated-markdown/EncapsulateTransformObject.generated.md'

<API />
