Registry / api / relay-runtime

relay-runtime

JSON →
library21.0.1jsnpmunverified

Relay Runtime is the core runtime library for building GraphQL-driven applications with the Relay framework, developed by Facebook. Current stable version is 21.0.1, released bi-weekly alongside the Relay compiler. It provides client-side GraphQL execution, data fetching, caching with normalized stores, and reactivity. Key differentiators: strong type safety via generated TypeScript types, declarative data fetching with fragments, and optimized batching. Supports React and other JS frameworks. Ships TypeScript definitions natively.

api
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RelayRuntime is a named export, not default. Use object destructuring.

import { RelayRuntime } from 'relay-runtime'

Since v11, relay-runtime is ESM-only. Use import syntax; require() fails.

import { Environment } from 'relay-runtime'

fetchQuery is a named export. Default import yields undefined.

import { fetchQuery } from 'relay-runtime'

Shows how to create a Relay environment with a network layer and store.

import { Environment, Network, RecordSource, Store } from 'relay-runtime'; const fetchRelay = async (params, variables) => { const response = await fetch('https://api.example.com/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query: params.text, variables, }), }); return response.json(); }; const environment = new Environment({ network: Network.create(fetchRelay), store: new Store(new RecordSource()), }); export default environment;
Debug
Known footguns
breakingRelay Environment is no longer a singleton; multiple environments are supported with different caches.
breakingRelayRuntime no longer exports 'Relay' default; use named exports like Environment.
deprecatedcommitMutation and requestSubscription are deprecated in favor of useMutation and useSubscription hooks.
gotchaImporting from 'relay-runtime/lib/...' is unsupported; internal paths may change without notice.
gotchaTypeScript: some types are only available when using relay-compiler-generated files; manual usage may lack types.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
19 hits · last 30 days
gptbot
3
bytedance
3
ahrefsbot
1
Resources