Created
October 1, 2017 02:43
-
-
Save feus4177/d489e714a5fd3cf30fe4953d8b124484 to your computer and use it in GitHub Desktop.
Example environment configuration for RelayJS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetch from 'isomorphic-fetch'; | |
import {Environment, Network, RecordSource, Store, RecordSourceInspector} from 'relay-runtime'; | |
const source = new RecordSource(); | |
const store = new Store(source); | |
const inspector = new RecordSourceInspector(source); | |
const network = Network.create((operation, variables) => ( | |
fetch('http://localhost/api/v2/graphql/'), { | |
method: 'POST', | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json', | |
}, | |
body: JSON.stringify({ | |
query: operation.text, | |
variables, | |
}), | |
}).then((response) => response.json()) | |
)); | |
const environment = new Environment({ | |
network, | |
store, | |
}); | |
export {inspector}; | |
export default environment; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment