Skip to main content

Rename Transform

The rename transform allow you rename GraphQL types and GraphQL fields easily.

yarn add @graphql-mesh/transform-rename

How to use?#

Add the following configuration to your Mesh config file:

transforms:
- rename:
mode: bare | wrap
renames:
- from:
type: ApiUser
to:
type: User
- from:
type: Query
field: apiUser
to:
type: Query
field: user

or you can use regular expressions to rename multiple types, fields or both

- rename:
mode: bare | wrap
renames:
- from:
type: Api(.*)
to:
type: $1
useRegExpForTypes: true
- from:
type: Query
field: api(.*)
to:
type: Query
field: $1
useRegExpForFields: true

For information about "bare" and "wrap" modes, please read the dedicated section.

Config API Reference#

  • mode (type: String (bare | wrap)) - Specify to apply rename transforms to bare schema or by wrapping original schema
  • renames (type: Array of Object, required) - Array of rename rules:
    • from (type: Object, required):
      • type (type: String)
      • field (type: String)
    • to (type: Object, required):
      • type (type: String)
      • field (type: String)
    • useRegExpForTypes (type: Boolean) - Use Regular Expression for type names
    • useRegExpForFields (type: Boolean) - Use Regular Expression for field names