Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@john-nash-rs
Created August 7, 2020 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john-nash-rs/085219026dd77b04d05e5197960aafe3 to your computer and use it in GitHub Desktop.
Save john-nash-rs/085219026dd77b04d05e5197960aafe3 to your computer and use it in GitHub Desktop.
import {
Environment,
Network,
RecordSource,
Store,
} from 'relay-runtime';
function fetchQuery(
operation,
variables,
) {
return fetch('http://localhost:8080/graphql', {
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