Skip to content

Commit

Permalink
simplify webpack example
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Mar 24, 2023
1 parent 5077414 commit 6846d44
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions example/webpack-example/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,26 @@ import * as ReactDOMClient from 'react-dom/client';

import { Voyager } from 'graphql-voyager';

class Test extends React.Component {
constructor() {
super();
}

render() {
return (
<Voyager
introspection={this.introspectionProvider}
displayOptions={{ skipRelay: false, showLeafFields: true }}
/>
);
}

async introspectionProvider(query) {
const response = await fetch('https://swapi-graphql.netlify.app/.netlify/functions/index', {
async function introspectionProvider(query) {
const response = await fetch(
'https://swapi-graphql.netlify.app/.netlify/functions/index',
{
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({ query }),
credentials: 'omit',
});
return response.json();
}
},
);
return response.json();
}

const reactRoot = ReactDOMClient.createRoot(document.getElementById('voyager'));
reactRoot.render(<Test />);
reactRoot.render(
<Voyager
introspection={introspectionProvider}
displayOptions={{ skipRelay: false, showLeafFields: true }}
/>,
);

0 comments on commit 6846d44

Please sign in to comment.