Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
make preConfig a prop of AppWrapperProvideUrqlClient
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiSakuma committed Aug 17, 2023
1 parent 5f0f9c5 commit 4e3c721
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/app/AppWrapperLoadPreConfig.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<template>
<app v-if="!(loading || error)"> </app>
<div v-else-if="error">{{ error }}</div>
<div v-if="error">{{ error }}</div>
<div v-else-if="loading">Loading...</div>
<app v-else-if="preConfig" :pre-config="preConfig"> </app>
</template>

<script setup lang="ts">
import { storeToRefs } from "pinia";
import { usePreConfigStore } from "@/stores/pre-config";
import App from "./AppWrapperProvideUrqlClient.vue";
const { loading, error } = storeToRefs(usePreConfigStore());
const { preConfig, loading, error } = storeToRefs(usePreConfigStore());
</script>
12 changes: 8 additions & 4 deletions src/app/AppWrapperProvideUrqlClient.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@

<script setup lang="ts">
import { ref } from "vue";
import { usePreConfigStore } from "@/stores/pre-config";
import { PreConfig } from "@/stores/pre-config";
import { provideClient } from "@urql/vue";
import { createUrqlClient } from "@/plugins/urql";
import App from "./AppWrapperAuth.vue";
const preConfigStore = usePreConfigStore();
const url = preConfigStore.preConfig?.graphqlHttp;
if (!url) throw new Error("api url is not found");
interface Props {
preConfig: PreConfig;
}
const prop = defineProps<Props>();
const url = prop.preConfig.graphqlHttp;
const urqlClient = ref(createUrqlClient(url));
provideClient(urqlClient);
</script>
2 changes: 1 addition & 1 deletion src/stores/pre-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineStore } from "pinia";
import { useAxios } from "@vueuse/integrations/useAxios";
import * as path from "path";

interface PreConfig {
export interface PreConfig {
graphqlHttp: string;
}

Expand Down

0 comments on commit 4e3c721

Please sign in to comment.