graphiql.js 426 B

123456789101112131415161718
  1. import React from 'react'
  2. import ReactDOM from 'react-dom'
  3. import GraphiQL from 'graphiql'
  4. import axios from 'axios'
  5. import 'graphiql/graphiql.css'
  6. function fetcher (params) {
  7. return axios.post(
  8. '/api/graphql',
  9. JSON.stringify(params),
  10. {
  11. headers: {'Content-Type': 'application/json'},
  12. }
  13. ).then(({data}) => data)
  14. }
  15. ReactDOM.render(<GraphiQL fetcher={fetcher} />, document.getElementById('graphiql'))