Use Relay without a GraphQL server.
!Codecovcodecov-badgecodecov !Discorddiscord-badgediscord
This will execute queries against the specified schema locally, rather than against a separate GraphQL server.
You can also specify a GraphQL.js
For more control over the network layer, you can use
!Codecovcodecov-badgecodecov !Discorddiscord-badgediscord
Usage
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 })),
/* ... */
});