The core of Relay is the fetchQuery function. This function sends requests to your GraphQL endpoint. One of the parameters to the fetchQuery function is the environment, and we'll set this up in this section. This is an object of type Environment. We create it once and export it via a getEnvironment function, which our sagas will be able to call.
One of the arguments that the Environment object requires is a function that actually performs the fetch by calling window.fetch. We'll call this performFetch function and we'll start by building it first, and then move on to getEnvironment.
The Relay environment is an extension point for Relay, where all manner of functionality can be added. Data caching is one example. If you're interested in how to do that, check out the Further learning section at the end of this chapter.
The file...