File tree Expand file tree Collapse file tree 2 files changed +30
-50
lines changed
packages/test-e2e-composable-vue3/src/components Expand file tree Collapse file tree 2 files changed +30
-50
lines changed Original file line number Diff line number Diff line change 1
- <script lang="ts">
1
+ <script lang="ts" setup >
2
2
import gql from ' graphql-tag'
3
3
import { useQuery } from ' @vue/apollo-composable'
4
- import { defineComponent , computed } from ' vue'
4
+ import { computed } from ' vue'
5
5
6
6
interface Channel {
7
7
id: string
8
8
label: string
9
9
}
10
10
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
30
15
}
31
- },
32
- })
16
+ }
17
+
18
+ fragment channel on Channel {
19
+ id
20
+ label
21
+ }
22
+ ` )
23
+ const channels = computed (() => result .value ?.channels ?? [])
33
24
</script >
34
25
35
26
<template >
Original file line number Diff line number Diff line change 1
- <script lang="ts">
1
+ <script lang="ts" setup >
2
2
import gql from ' graphql-tag'
3
3
import { useLazyQuery } from ' @vue/apollo-composable'
4
- import { defineComponent , computed , ref } from ' vue'
4
+ import { computed , ref } from ' vue'
5
5
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 ?? [])
14
12
15
- const refetched = ref (false )
13
+ const refetched = ref (false )
16
14
17
- function r () {
18
- refetched .value = true
19
- refetch ()
20
- }
15
+ function r () {
16
+ refetched .value = true
17
+ refetch ()
18
+ }
21
19
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
+ }
34
23
</script >
35
24
36
25
<template >
You can’t perform that action at this time.
0 commit comments