graphql.vue 2.0 KB

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