Nearly Perpendicular Macaroons

    relay-runtime
    DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/relay-runtime package

    14.0.0 • Public • Published

    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

    Install

    npm i relay-runtime

    Homepage

    relay.dev

    DownloadsWeekly Downloads

    1,796,209

    Version

    14.0.0

    License

    MIT

    Unpacked Size

    1.63 MB

    Total Files

    226

    Last publish

    Collaborators

    • alunyov
    • rbalicki
    • sugarpirate
    • fb
    • yuzhi
    • kassens
    • xiaobu
    • lunaruan
    • relay-bot
    • kacieb