---
description:
  The Rename Transform in GraphQL Mesh allows you to rename types, fields, and field arguments,
  making queries look more like mutations. Learn how to use this transform and its RegEx feature in
  this guide.
---

import { Callout } from '@theguild/components'

# Rename Transform

The rename transform allows you to rename:

- GraphQL types
- GraphQL fields
- GraphQL field arguments

The `rename` transform helps you avoid conflicting names, simplify complicated names and make
queries look more like mutations.

## How to use?

You can import `createRenameTransform` to create an instance of the transform. You can use regular
JavaScript functions to rename types, fields, and field arguments.

```ts filename="mesh.config.ts" {13-17}
import {
  createRenameTransform,
  defineConfig,
  loadGraphQLHTTPSubgraph
} from '@graphql-mesh/compose-cli'

export const composeConfig = defineConfig({
  subgraphs: [
    {
      sourceHandler: loadGraphQLHTTPSubgraph('Countries', {
        endpoint: 'https://countries.trevorblades.com'
      }),
      transforms: [
        createRenameTransform({
          // Rename types
          typeRenamer(opts) {
            if (opts.typeName === 'Country') {
              return 'MyCountry'
            }
            return ''
          },
          // Rename fields
          fieldRenamer(opts) {
            if (opts.typeName === 'Country' && opts.fieldName === 'name') {
              return 'countryName'
            }
            return ''
          },
          // Rename field arguments
          argRenamer(opts) {
            if (
              opts.typeName === 'Country' &&
              opts.fieldName === 'name' &&
              opts.argName === 'lang'
            ) {
              return 'language'
            }
            return ''
          }
        })
      ]
    }
  ]
})
```
