Skip to content

Commit 6846d44

Browse files
committed
simplify webpack example
1 parent 5077414 commit 6846d44

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

example/webpack-example/index.jsx

+13-20
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,26 @@ import * as ReactDOMClient from 'react-dom/client';
33

44
import { Voyager } from 'graphql-voyager';
55

6-
class Test extends React.Component {
7-
constructor() {
8-
super();
9-
}
10-
11-
render() {
12-
return (
13-
<Voyager
14-
introspection={this.introspectionProvider}
15-
displayOptions={{ skipRelay: false, showLeafFields: true }}
16-
/>
17-
);
18-
}
19-
20-
async introspectionProvider(query) {
21-
const response = await fetch('https://swapi-graphql.netlify.app/.netlify/functions/index', {
6+
async function introspectionProvider(query) {
7+
const response = await fetch(
8+
'https://swapi-graphql.netlify.app/.netlify/functions/index',
9+
{
2210
method: 'post',
2311
headers: {
2412
Accept: 'application/json',
2513
'Content-Type': 'application/json',
2614
},
2715
body: JSON.stringify({ query }),
2816
credentials: 'omit',
29-
});
30-
return response.json();
31-
}
17+
},
18+
);
19+
return response.json();
3220
}
3321

3422
const reactRoot = ReactDOMClient.createRoot(document.getElementById('voyager'));
35-
reactRoot.render(<Test />);
23+
reactRoot.render(
24+
<Voyager
25+
introspection={introspectionProvider}
26+
displayOptions={{ skipRelay: false, showLeafFields: true }}
27+
/>,
28+
);

0 commit comments

Comments
 (0)