⚠️
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

Prefix Transform

The prefix transforms allow you to add prefixes to existing GraphQL types and root operations (under Query/Mutation). prefix is similar to rename in that it allows you to modify names to avoid conflicts, simplify complicated names, and change the appearance of your query. In contrast with rename, prefix is simpler and only allows you to append a prefix to the existing name.

You can use it to easily “namespace” APIs in your unified API and avoid conflicts.

Installation

npm i @graphql-mesh/transform-prefix

How to use?

Add the following configuration to your Mesh config file:

.meshrc.yaml
transforms:
  - prefix:
      mode: bare | wrap
      value: MyApi_
💡

For information about “bare” and “wrap” modes, please read the dedicated section. You can check out our example that uses schema stitching with a PostgreSQL data source and prefix transform. Click here to open the example on GitHub.

Config API Reference

  • mode (type: String (bare | wrap)) - Specify to apply prefix transform to bare schema or by wrapping original schema
  • value (type: String) - The prefix to apply to the schema types. By default it’s the API name.
  • ignore (type: Array of String, required) - List of ignored types
  • includeRootOperations (type: Boolean) - Changes root types and changes the field names (default: false)
  • includeTypes (type: Boolean) - Changes types (default: true)