Skip to content

Commit c8e5106

Browse files
committed
chore: switch some tests to script setup
1 parent 4679a04 commit c8e5106

File tree

2 files changed

+30
-50
lines changed

2 files changed

+30
-50
lines changed

packages/test-e2e-composable-vue3/src/components/ChannelList.vue

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,26 @@
1-
<script lang="ts">
1+
<script lang="ts" setup>
22
import gql from 'graphql-tag'
33
import { useQuery } from '@vue/apollo-composable'
4-
import { defineComponent, computed } from 'vue'
4+
import { computed } from 'vue'
55
66
interface Channel {
77
id: string
88
label: string
99
}
1010
11-
export default defineComponent({
12-
setup () {
13-
const { result, loading } = useQuery<{ channels: Channel[] }>(gql`
14-
query channels {
15-
channels {
16-
...channel
17-
}
18-
}
19-
20-
fragment channel on Channel {
21-
id
22-
label
23-
}
24-
`)
25-
const channels = computed(() => result.value?.channels ?? [])
26-
27-
return {
28-
loading,
29-
channels,
11+
const { result, loading } = useQuery<{ channels: Channel[] }>(gql`
12+
query channels {
13+
channels {
14+
...channel
3015
}
31-
},
32-
})
16+
}
17+
18+
fragment channel on Channel {
19+
id
20+
label
21+
}
22+
`)
23+
const channels = computed(() => result.value?.channels ?? [])
3324
</script>
3425

3526
<template>

packages/test-e2e-composable-vue3/src/components/LazyQuery.vue

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,25 @@
1-
<script lang="ts">
1+
<script lang="ts" setup>
22
import gql from 'graphql-tag'
33
import { useLazyQuery } from '@vue/apollo-composable'
4-
import { defineComponent, computed, ref } from 'vue'
4+
import { computed, ref } from 'vue'
55
6-
export default defineComponent({
7-
setup () {
8-
const { result, loading, load, refetch } = useLazyQuery(gql`
9-
query list {
10-
list
11-
}
12-
`)
13-
const list = computed(() => result.value?.list ?? [])
6+
const { result, loading, load, refetch } = useLazyQuery(gql`
7+
query list {
8+
list
9+
}
10+
`)
11+
const list = computed(() => result.value?.list ?? [])
1412
15-
const refetched = ref(false)
13+
const refetched = ref(false)
1614
17-
function r () {
18-
refetched.value = true
19-
refetch()
20-
}
15+
function r () {
16+
refetched.value = true
17+
refetch()
18+
}
2119
22-
function loadOrRefetch () {
23-
load() || r()
24-
}
25-
26-
return {
27-
loadOrRefetch,
28-
loading,
29-
list,
30-
refetched,
31-
}
32-
},
33-
})
20+
function loadOrRefetch () {
21+
load() || r()
22+
}
3423
</script>
3524

3625
<template>

0 commit comments

Comments
 (0)