rano/web/routes/+layout.svelte

25 lines
635 B
Svelte

<script lang="ts">
import { beforeNavigate } from '$app/navigation';
import { updated } from '$app/stores';
import { setContextClient } from '@urql/svelte';
import { newClient } from '$lib/gql/client';
import { Me } from '$lib/gql/account.gql';
import '../app.css';
const { children } = $props();
const host = import.meta.env.VITE_GRAPH_URL ?? '';
const client = newClient(`${host}/query`);
setContextClient(client);
beforeNavigate(({ willUnload, to }) => {
if ($updated && !willUnload && to?.url) {
location.href = to.url.href;
}
});
const p = client.query(Me, {}).toPromise();
</script>
{@render children()}