In order to know how to access your GraphQL server, Relay requires developers to provide an object implementing the
INetwork interface when creating an instance of a Relay Environment. The environment uses this network layer to execute queries, mutations, and (if your server supports them) subscriptions. This allows developers to use whatever transport (HTTP, WebSockets, etc) and authentication is most appropriate for their application, decoupling the environment from the particulars of each application's network configuration.
Currently the easiest way to create a network layer is via a helper from the
Note that this is a basic example to help you get started. This example could be extended with additional features such as request/response caching (enabled e.g. when
cacheConfig.force is false) and uploading form data for mutations (the
The Relay store will cache data from queries that are currently retained. See the section on reusing cached data of the guided tour.
Is this page useful?