Skip to content

Commit d51fae0

Browse files
captbaritonefacebook-github-bot
authored andcommitted
Document configuring relay runtime globally (#4906)
Summary: In helping an internal team onboard I realized the ConnectionInterface runtime config is not documented. This aims to fill that gap and also document our other global runtime config: FeatureFlags. Pull Request resolved: #4906 Test Plan: ![Screenshot 2025-02-03 at 4 50 37 PM](https://github.com/user-attachments/assets/43383c4c-aada-474c-9442-77978376a0e9) Reviewed By: lynnshaoyu Differential Revision: D69088021 Pulled By: captbaritone fbshipit-source-id: 3722a429ee7f903e44ba7a11ace08c98964110b3
1 parent a5d6b23 commit d51fae0

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
id: runtime-config
3+
title: Runtime Configuration
4+
slug: /api-reference/runtime-config/
5+
description: Configuring the Relay Runtime
6+
keywords:
7+
- feature flags
8+
- configuration
9+
---
10+
11+
## ConnectionInterface
12+
13+
If your server's implementation of the Connection Spec differs from the default interface you will need to configure the Relay Runtime to expect the connection type and field names used in your schema. This is done by updating the global ConnectionInterface instance exported by Relay:
14+
15+
:::note
16+
You will also need to update your Relay Compiler Config with these same values.
17+
:::
18+
19+
```ts title="/src/ConfigureRelay.ts"
20+
import { ConnectionInterface } from 'relay-runtime';
21+
22+
// Note: This must match the values configured in the Relay compiler config.
23+
ConnectionInterface.inject({
24+
END_CURSOR: 'end_cursor',
25+
HAS_NEXT_PAGE: 'has_next_page',
26+
HAS_PREV_PAGE: 'has_previous_page',
27+
START_CURSOR: 'start_cursor',
28+
PAGE_INFO: 'page_info',
29+
NODE: 'node',
30+
CURSOR: 'cursor',
31+
EDGES: 'edges',
32+
PAGE_INFO_TYPE: 'PageInfo',
33+
});
34+
```
35+
36+
## Feature Flags
37+
38+
:::warning
39+
Feature Flags are used for enabling and configuring unstable Relay features, **regular use of Relay should not need to modify runtime feature flags**. They are documented here for purely informational purposes
40+
:::
41+
42+
Relay has a number of runtime options called "Feature Flags". In general, these are used for enabling experimental features which are not yet stable and thus not yet enabled by default.
43+
44+
Feature flags in the Relay Runtime are implemented as a global mutable object. To set/configure a feature flag, import that object and mutate it. If you do this in the module scope, the updates will apply before Relay looks at them.
45+
46+
```ts title="/src/ConfigureRelay.ts"
47+
import { RelayFeatureFlags } from 'relay-runtime';
48+
49+
RelayFeatureFlags.ENABLE_SOME_EXPERIMENT = true;
50+
```
51+
52+
You can find the full list of feature flags [here](https://github.com/facebook/relay/blob/203d8b10e9144a37466b8a72edbe6add48f64e7d/packages/relay-runtime/util/RelayFeatureFlags.js#L4), but keep in mind that **feature flags may change arbitrarily between versions of Relay**.

website/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ module.exports = {
219219
'api-reference/relay-runtime/request-subscription',
220220
'api-reference/relay-runtime/observe-fragment',
221221
'api-reference/relay-runtime/wait-for-fragment-data',
222+
'api-reference/relay-runtime/runtime-config',
222223
],
223224
},
224225
{

0 commit comments

Comments
 (0)