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 >
22import gql from ' graphql-tag'
33import { useQuery } from ' @vue/apollo-composable'
4- import { defineComponent , computed } from ' vue'
4+ import { computed } from ' vue'
55
66interface 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 >
Original file line number Diff line number Diff line change 1- <script lang="ts">
1+ <script lang="ts" setup >
22import gql from ' graphql-tag'
33import { 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 >
You can’t perform that action at this time.
0 commit comments