graphql.vue 2.1 KB

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