Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/relay-tools/relay-local-schema
Use Relay without a GraphQL server
https://github.com/relay-tools/relay-local-schema
Last synced: 5 days ago
JSON representation
Use Relay without a GraphQL server
- Host: GitHub
- URL: https://github.com/relay-tools/relay-local-schema
- Owner: relay-tools
- License: cc0-1.0
- Created: 2015-09-07T20:15:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-10-10T14:12:23.000Z (2 months ago)
- Last Synced: 2024-10-12T18:53:32.276Z (2 months ago)
- Language: JavaScript
- Size: 1.34 MB
- Stars: 253
- Watchers: 5
- Forks: 11
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-graphql - relay-local-schema - Use Relay without a GraphQL server. (Libraries / JavaScript Libraries)
- awesome-list - relay-local-schema - tools | 249 | (JavaScript)
- awesome-relay - `relay-local-schema` - Use a local schema; no need for a remote GraphQL server. (Tooling)
- awesome-graphql - relay-local-schema - Use Relay without a GraphQL server. (Libraries / JavaScript Libraries)
README
# Relay Local Schema [![Travis][build-badge]][build] [![npm][npm-badge]][npm]
Use [Relay](https://relay.dev/) without a GraphQL server.
[![Codecov][codecov-badge]][codecov]
[![Discord][discord-badge]][discord]## Usage
```js
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`:
```js
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.
```js
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 })),
/* ... */
});
```## 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.
[build-badge]: https://img.shields.io/travis/relay-tools/relay-local-schema/master.svg
[build]: https://travis-ci.org/relay-tools/relay-local-schema[npm-badge]: https://img.shields.io/npm/v/relay-local-schema.svg
[npm]: https://www.npmjs.org/package/relay-local-schema[codecov-badge]: https://img.shields.io/codecov/c/github/relay-tools/relay-local-schema/master.svg
[codecov]: https://codecov.io/gh/relay-tools/relay-local-schema[discord-badge]: https://img.shields.io/badge/Discord-join%20chat%20%E2%86%92-738bd7.svg
[discord]: https://discord.gg/0ZcbPKXt5bX40xsQ