Skip to content

Commit

Permalink
fix result gen
Browse files Browse the repository at this point in the history
  • Loading branch information
Applelo committed Jun 1, 2024
1 parent b872e41 commit 8cec114
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions components/Result.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ const props = defineProps<{
loading: boolean
}>()
const body = computed(() => {
return {
schema: props.rawSchema,
}
})
const selected = ref(0)
const {data: rawTs, execute: executeGqlToTs } = await useFetch('/api/gql-to-ts', {
const { data: rawTs, execute: executeGqlToTs } = await useFetch('/api/gql-to-ts', {
method: 'POST',
body: {
schema: props.rawSchema,
},
body,
immediate: false,
server: false
server: false,
watch: false,
})
const items = [{
label: 'Schema',
}, {
Expand All @@ -29,14 +32,14 @@ function codeToClipboard() {
copy(props.rawSchema)
toast.add({
title: 'Copied',
description: 'The schema is in your clipboard!'
description: 'The schema is in your clipboard!',
})
}
else if (selected.value === 1 && rawTs.value) {
copy(rawTs.value)
toast.add({
title: 'Copied',
description: 'The TypeScript code is in your clipboard!'
description: 'The TypeScript code is in your clipboard!',
})
}
}
Expand Down Expand Up @@ -65,10 +68,10 @@ watch(selected, async () => {
</div>
</template>
<LazyShiki
v-if="rawSchema && selected === 0"
lang="graphql"
class="max-h-screen overflow-auto"
:code="rawSchema"
v-if="rawSchema && selected === 0"
lang="graphql"
class="max-h-screen overflow-auto"
:code="rawSchema"
/>
<LazyShiki
v-else-if="rawTs && selected === 1"
Expand Down

0 comments on commit 8cec114

Please sign in to comment.