graphql.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <AppPaneLayout layout-id="graphql">
  3. <template #primary>
  4. <GraphqlRequest :conn="gqlConn" />
  5. <GraphqlRequestOptions :conn="gqlConn" />
  6. </template>
  7. <template #secondary>
  8. <GraphqlResponse :conn="gqlConn" />
  9. </template>
  10. <template #sidebar>
  11. <GraphqlSidebar :conn="gqlConn" />
  12. </template>
  13. </AppPaneLayout>
  14. </template>
  15. <script lang="ts">
  16. import { defineComponent, watch } from "@nuxtjs/composition-api"
  17. import { GQLConnection } from "~/helpers/GQLConnection"
  18. import { useNuxt, useReadonlyStream } from "~/helpers/utils/composables"
  19. export default defineComponent({
  20. beforeRouteLeave(_to, _from, next) {
  21. if (this.gqlConn.connected$.value) {
  22. this.gqlConn.disconnect()
  23. }
  24. next()
  25. },
  26. setup() {
  27. const nuxt = useNuxt()
  28. const gqlConn = new GQLConnection()
  29. const isLoading = useReadonlyStream(gqlConn.isLoading$, false)
  30. watch(isLoading, () => {
  31. if (isLoading.value) nuxt.value.$loading.start()
  32. else nuxt.value.$loading.finish()
  33. })
  34. return {
  35. gqlConn,
  36. }
  37. },
  38. head() {
  39. return {
  40. title: `${this.$t("navigation.graphql")} • Hoppscotch`,
  41. }
  42. },
  43. })
  44. </script>