Created
August 25, 2017 15:13
-
-
Save gc-codesnippets/8706e3f1f79e726e0c8abf614bc2cf8a 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('https://api.graph.cool/relay/v1/cj1nq71xyfabv0199bp3a7hhf', { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ | |
query: operation.text, | |
variables, | |
}), | |
}).then(response => { | |
return response.json() | |
}) | |
} | |
const network = Network.create(fetchQuery) | |
const source = new RecordSource() | |
const store = new Store(source) | |
export default new Environment({ | |
network, | |
store | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment