relay-runtime
A core runtime for building GraphQL-driven applications.
Last updated 4 years ago by alunyov .
MIT · Repository · Bugs · Original npm
$ cnpm install relay-runtime 
SYNC missed versions from official npm registry.

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/.

Current Tags

  • 2.0.0-rc.2                                ...           dev (7 years ago)
  • 9.1.0                                ...           latest (5 years ago)
  • 0.0.0-master-43ae013b                                ...           master (5 years ago)
  • 1.6.2                                ...           publish-test (7 years ago)

15 Versions

  • 0.0.0-main-6b7c7b2f                                ...           3 years ago
  • 14.0.0                                ...           3 years ago
  • 10.0.0                                ...           5 years ago
  • 10.0.1                                ...           5 years ago
  • 11.0.2                                ...           4 years ago
  • 0.0.0-main-6bdab0d6                                ...           3 years ago
  • 13.2.0                                ...           3 years ago
  • 13.0.0-rc.2                                ...           4 years ago
  • 12.0.0                                ...           4 years ago
  • 1.4.1                                ...           8 years ago
  • 1.6.2                                ...           7 years ago
  • 0.0.0-master-43ae013b                                ...           5 years ago
  • 9.1.0                                ...           5 years ago
  • 2.0.0-rc.2                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org