Rename Transform
GraphQL Mesh v0 documentation (superseded by v1): 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.
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.
rename elements can contain arrays of individual renaming operations, defined in separate renames
objects. Each of these objects must define the from and to values.
Installation
How to use?
Add the following configuration to your Mesh config file:
RegEx example
You can use RegEx flags to enable the use of regular expressions when renaming using this transform. This way you can rename multiple types, fields or both. For example, you could use the key value pair field: api(.*) in the from object to rename any field of the corresponding type that begins with “api”.
Config API Reference
mode(type:String (bare | wrap)) - Specify to apply rename transforms to bare schema or by wrapping original schemarenames(type:Array of Object, required) - Array of rename rules:from(type:Object, required):type(type:String)field(type:String)argument(type:String)
to(type:Object, required):type(type:String)field(type:String)argument(type:String)
useRegExpForTypes(type:Boolean) - Use Regular Expression for type namesuseRegExpForFields(type:Boolean) - Use Regular Expression for field namesuseRegExpForArguments(type:Boolean) - Use Regular Expression for field namesregExpFlags(type:String) - Flags to use in the Regular ExpressionincludeDefaults(type:Boolean) - Flag to indicate whether certain default types (built-ins, scalars and other types specified an exclusion list) should be renamed or not.
@default: false