On this page

Prefix Transform

GraphQL Mesh v0 documentation (superseded by v1): Add prefixes to GraphQL types and operations using Prefix Transform in GraphQL Mesh. Simplify complicated names, avoid conflicts, and "namespace" APIs easily. Learn how to use it with examples and API reference.

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_

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)
  • force (type: Array of String, required) - Protected custom scalars (e.g. from graphql-scalars) to still prefix. GraphQL specified scalars (Int, Float, String, Boolean, ID) always stay unprefixed.