Skip to content

Commit

Permalink
chore: switch some tests to script setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Aug 19, 2024
1 parent 4679a04 commit c8e5106
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 50 deletions.
37 changes: 14 additions & 23 deletions packages/test-e2e-composable-vue3/src/components/ChannelList.vue
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
<script lang="ts">
<script lang="ts" setup>
import gql from 'graphql-tag'
import { useQuery } from '@vue/apollo-composable'
import { defineComponent, computed } from 'vue'
import { computed } from 'vue'
interface Channel {
id: string
label: string
}
export default defineComponent({
setup () {
const { result, loading } = useQuery<{ channels: Channel[] }>(gql`
query channels {
channels {
...channel
}
}
fragment channel on Channel {
id
label
}
`)
const channels = computed(() => result.value?.channels ?? [])
return {
loading,
channels,
const { result, loading } = useQuery<{ channels: Channel[] }>(gql`
query channels {
channels {
...channel
}
},
})
}
fragment channel on Channel {
id
label
}
`)
const channels = computed(() => result.value?.channels ?? [])
</script>

<template>
Expand Down
43 changes: 16 additions & 27 deletions packages/test-e2e-composable-vue3/src/components/LazyQuery.vue
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
<script lang="ts">
<script lang="ts" setup>
import gql from 'graphql-tag'
import { useLazyQuery } from '@vue/apollo-composable'
import { defineComponent, computed, ref } from 'vue'
import { computed, ref } from 'vue'
export default defineComponent({
setup () {
const { result, loading, load, refetch } = useLazyQuery(gql`
query list {
list
}
`)
const list = computed(() => result.value?.list ?? [])
const { result, loading, load, refetch } = useLazyQuery(gql`
query list {
list
}
`)
const list = computed(() => result.value?.list ?? [])
const refetched = ref(false)
const refetched = ref(false)
function r () {
refetched.value = true
refetch()
}
function r () {
refetched.value = true
refetch()
}
function loadOrRefetch () {
load() || r()
}
return {
loadOrRefetch,
loading,
list,
refetched,
}
},
})
function loadOrRefetch () {
load() || r()
}
</script>

<template>
Expand Down

0 comments on commit c8e5106

Please sign in to comment.