Socket
Book a DemoInstallSign in
Socket

relay-local-schema-nodonisko

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

relay-local-schema-nodonisko

Use Relay without a GraphQL server

0.6.3
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Relay Local Schema Travis npm

Use Relay without a GraphQL server.

Discord

Usage

Relay Modern

import { Environment } from 'react-relay';
import { Network } from 'relay-local-schema';

import schema from './data/schema';

const environment = new Environment({
  network: Network.create({ schema }),
  /* ... */
});

This will execute queries against the specified schema locally, rather than against a separate GraphQL server.

You can also specify a GraphQL.js rootValue or contextValue:

const environment = new Environment({
  network: Network.create({
    schema,
    rootValue: 'foo',
    contextValue: 'bar',
  }),
  /* ... */
});

For more control over the network layer, you can use createFetch to create just the fetch function.

import { Environment, Network } from 'react-relay';
import { createFetch } from 'relay-local-schema';

import schema from './data/schema';

const environment = new Environment({
  network: Network.create(createFetch({ schema })),
  /* ... */
});

Relay Classic

import RelayLocalSchema from 'relay-local-schema/lib/classic';

import schema from './data/schema';

Relay.injectNetworkLayer(
  new RelayLocalSchema.NetworkLayer({ schema })
);

This will execute queries against the specified schema locally, rather than against a separate GraphQL server.

You can also supply a GraphQL.js rootValue or contextValue, or an onError callback:

Relay.injectNetworkLayer(
  new RelayLocalSchema.NetworkLayer({
    schema,
    rootValue: 'foo',
    contextValue: 'bar',
    onError: (errors, request) => console.error(errors, request),
  })
);

Caveat

This is intended for exploratory work, integration tests, demos, and working with local data. This is not generally intended as a substitute for a remote GraphQL back end in production.

Keywords

relay

FAQs

Package last updated on 27 Mar 2018

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.