Last active
January 28, 2020 06:16
-
-
Save jelorivera08/37cf7829d2cad7eef7f489e4840bd305 to your computer and use it in GitHub Desktop.
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 { Environment, Network, RecordSource, Store } from 'relay-runtime'; | |
function fetchQuery(operation, variables) { | |
return fetch('http://localhost:4000', { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ | |
query: operation.text, | |
variables | |
}) | |
}).then(response => { | |
return response.json(); | |
}); | |
} | |
const environment = new Environment({ | |
network: Network.create(fetchQuery), | |
store: new Store(new RecordSource()) | |
}); | |
export default environment; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment