forked from graphql-kit/graphql-voyager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.jsx
32 lines (28 loc) · 766 Bytes
/
index.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Voyager } from 'graphql-voyager';
import fetch from 'isomorphic-fetch';
class Test extends React.Component {
constructor() {
super();
}
render() {
return (
<Voyager
introspection={this.introspectionProvider}
displayOptions={{ skipRelay: false, showLeafFields: true }}
/>
);
}
introspectionProvider(query) {
return fetch('http://swapi.apis.guru', {
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({ query }),
}).then((response) => response.json());
}
}
ReactDOM.render(<Test />, document.getElementById('voyager'));