Code Generator API

manifest

The object that names a generator and says which requests it exports.

Declaration

var manifest = {
  id: string,
  name: string,
  group?: string,
  language?: string,
  fileExtension?: string,
  order?: number,
  kind?: 'http' | 'websocket'
};

Overview

Every generator declares a top-level variable named manifest. Relay reads it when it loads the generator, before it ever calls generate, to list the generator in the Preview panel's format menu and in the Exporters pane of Relay > Settings.

var manifest = {
  id: 'python-httpx',
  name: 'HTTPX',
  group: 'Python',
  language: 'python',
  fileExtension: 'py',
  order: 32
};

Keep the manifest a plain object literal. Relay evaluates the whole file to read it, so a syntax error anywhere in the file keeps the generator from loading.

Properties

Prop

Type

Discussion

Generators with the same order in a group are sorted by name, and groups with the same lowest order by their heading. Relay's built-in generators use these orders, so a value between two of them places yours there:

OrderGroup
0Raw, without a group
10–12Shell
15PowerShell
20–22JavaScript
30–31Python
40Go
50–51Java
60–61C#
70–71PHP
80Ruby
90Swift
100Kotlin
110Rust
120C

A generator whose group matches a built-in group, such as 'Python', appears in that group.

A file without an id uses its file name as its id. Relay can't load a generator whose manifest is missing, has no name or names a kind other than 'http' or 'websocket', and leaves it out of the format menu.

See Also