Skip to content

Instantly share code, notes, and snippets.

@gc-codesnippets
Created August 25, 2017 15:13
Show Gist options
  • Save gc-codesnippets/8706e3f1f79e726e0c8abf614bc2cf8a to your computer and use it in GitHub Desktop.
Save gc-codesnippets/8706e3f1f79e726e0c8abf614bc2cf8a to your computer and use it in GitHub Desktop.
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