graphql.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <Splitpanes
  3. class="smart-splitter"
  4. :dbl-click-splitter="false"
  5. :horizontal="!(windowInnerWidth.x.value >= 768)"
  6. >
  7. <Pane class="hide-scrollbar !overflow-auto">
  8. <Splitpanes
  9. class="smart-splitter"
  10. :dbl-click-splitter="false"
  11. :horizontal="COLUMN_LAYOUT"
  12. >
  13. <Pane class="hide-scrollbar !overflow-auto">
  14. <GraphqlRequest :conn="gqlConn" />
  15. <GraphqlRequestOptions :conn="gqlConn" />
  16. </Pane>
  17. <Pane class="hide-scrollbar !overflow-auto">
  18. <GraphqlResponse :conn="gqlConn" />
  19. </Pane>
  20. </Splitpanes>
  21. </Pane>
  22. <Pane
  23. v-if="RIGHT_SIDEBAR"
  24. max-size="35"
  25. size="25"
  26. min-size="20"
  27. class="hide-scrollbar !overflow-auto"
  28. >
  29. <GraphqlSidebar :conn="gqlConn" />
  30. </Pane>
  31. </Splitpanes>
  32. </template>
  33. <script lang="ts">
  34. import { defineComponent, watch } from "@nuxtjs/composition-api"
  35. import { Splitpanes, Pane } from "splitpanes"
  36. import "splitpanes/dist/splitpanes.css"
  37. import { useSetting } from "~/newstore/settings"
  38. import { GQLConnection } from "~/helpers/GQLConnection"
  39. import { useNuxt, useReadonlyStream } from "~/helpers/utils/composables"
  40. import useWindowSize from "~/helpers/utils/useWindowSize"
  41. export default defineComponent({
  42. components: { Splitpanes, Pane },
  43. beforeRouteLeave(_to, _from, next) {
  44. if (this.gqlConn.connected$.value) {
  45. this.gqlConn.disconnect()
  46. }
  47. next()
  48. },
  49. setup() {
  50. const nuxt = useNuxt()
  51. const gqlConn = new GQLConnection()
  52. const isLoading = useReadonlyStream(gqlConn.isLoading$, false)
  53. watch(isLoading, () => {
  54. if (isLoading) nuxt.value.$loading.start()
  55. else nuxt.value.$loading.finish()
  56. })
  57. return {
  58. windowInnerWidth: useWindowSize(),
  59. RIGHT_SIDEBAR: useSetting("RIGHT_SIDEBAR"),
  60. COLUMN_LAYOUT: useSetting("COLUMN_LAYOUT"),
  61. gqlConn,
  62. }
  63. },
  64. head() {
  65. return {
  66. title: `${this.$t("navigation.graphql")} • Hoppscotch`,
  67. }
  68. },
  69. })
  70. </script>