added basic graphql mapping

This commit is contained in:
Samuel Andert 2023-08-07 15:01:30 +02:00
parent 0c202e0ef6
commit 783548581c
3 changed files with 63 additions and 39 deletions

View File

@ -12,5 +12,10 @@
<p>{todo.text}</p>
{/each}
{/if}
<br />
dataTest:
{#if $me.x}
{JSON.stringify($me.x)}
{/if}
</section>
</div>

View File

@ -59,6 +59,15 @@
if (component.data?.map) {
subscribeAndMapQueries(component.id, component.data.map);
}
if (component.data?.gql) {
getComposerStore(component.id).update((storeValue) => ({
...storeValue,
x: {
...storeValue.x,
...component.data.gql
}
}));
}
}
getComposerStore(component.id).update((storeValue) => ({
...storeValue,

View File

@ -1,58 +1,68 @@
<script lang="ts">
import type { PageData } from '../test/$houdini';
import Composer from '$lib/core/refactor/composer.svelte';
import Composer from '$lib/core/refactor/Composer.svelte';
import { queryTodos } from '$lib/data/queryTodos';
import { onMount } from 'svelte';
export let data: PageData;
let composer;
$: ({ queryTest } = data);
let composer = {
id: 'ComposerParent',
machine: {
initial: 'NOTREADY',
states: {
NOTREADY: {
on: { TOGGLE: 'READY' }
},
READY: {
on: { TOGGLE: 'NOTREADY' }
}
}
},
children: [
{
id: 'ComposerGraph',
component: 'ComposerGraph',
data: {
map: {
todos: queryTodos
onMount(async () => {
composer = await {
id: 'ComposerParent',
machine: {
initial: 'NOTREADY',
states: {
NOTREADY: {
on: { TOGGLE: 'READY' }
},
READY: {
on: { TOGGLE: 'NOTREADY' }
}
},
machine: {
initial: 'LOADING',
states: {
LOADING: {
on: {
TOGGLE: {
target: 'READY'
}
}
}
},
children: [
{
id: 'ComposerGraph',
component: 'ComposerGraph',
data: {
map: {
todos: queryTodos
},
READY: {
on: {
TOGGLE: {
target: 'LOADING'
gql: {
test: await $queryTest.data
}
},
machine: {
initial: 'LOADING',
states: {
LOADING: {
on: {
TOGGLE: {
target: 'READY'
}
}
},
READY: {
on: {
TOGGLE: {
target: 'LOADING'
}
}
}
}
}
}
}
]
};
]
};
});
</script>
{JSON.stringify($queryTest.data, null, 2)}
{#if $queryTest}
{JSON.stringify($queryTest.data, null, 2)}
{/if}
<Composer {composer} />