🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

relay-runtime

Package Overview
Dependencies
Maintainers
7
Versions
4106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

relay-runtime

A core runtime for building GraphQL-driven applications.

latest
Source
npmnpm
Version
20.1.1
Version published
Weekly downloads
4.7M
-18.83%
Maintainers
7
Weekly downloads
 
Created
Source

Relay Runtime

A set of Relay APIs responsible for data fetching, reading and normalization of the GraphQL data.

Example:

// @flow strict-local

import type {FetchFunction} from 'relay-runtime';

const {
  Environment,
  Network,
  Observable,
  RecordSource,
  Store,
  fetchQuery,
  graphql,
} = require('relay-runtime');

const fetchFn: FetchFunction = function (request, variables) {
  return new Observable.create(source => {
    fetch('/my-graphql-api', {
      method: 'POST',
      body: JSON.stringify({
        text: request.text,
        variables,
      }),
    })
      .then(response => response.json())
      .then(data => source.next(data));
  });
};

const network = Network.create(fetchFn);
const store = new Store(new RecordSource());
const environment = new Environment({
  network,
  store,
});

fetchQuery(
  environment,
  graphql`
    query AppQuery($id: ID!) {
      user(id: $id) {
        name
      }
    }
  `,
  {id: 'my-node-id'},
).subscribe({
  error: error => {
    console.error(error);
  },
  next: data => {
    console.log(data);
  },
});

For complete API reference, visit https://relay.dev/.

Keywords

graphql

FAQs

Package last updated on 06 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts