Open
Description
Describe the bug
I have created a composition function of car.
const {
load: loadCarByPk,
onResult: onResultCarByPk,
onError: onErrorCarByPk,
refetch: refetchCarByPk,
} = useLazyQuery(CAR_BY_PK_DOCUMENT)
Created a button which execute the composite function. the input value is 1.
function onClickFire2() {
let result = loadCarByPk(undefined, { id: inputId.value })
console.log("loadCarByPk, result -> ", result)
if (!result) {
console.log("refetch")
refetchCarByPk({ idList: inputId.value })
}
}
Following is my onResult
onResultCarByPk((result) => {
const { loading, data } = result
if (!loading) {
console.log("data -> ", data.car_by_pk)
}
})
To Reproduce
Steps to reproduce the behavior:
- Click on the button to trigger function. The following is my console.log()
loadCarByPk, result -> Promise {<pending>}
data -> {__typename: 'car', id: 1, name: 'Impreza WRX'}
- Click on the button second time to trigger the function again. The following is my console.log()
loadCarByPk, result -> false
refetch
data -> {__typename: 'car', id: 1, name: 'Impreza WRX'}
data -> {__typename: 'car', id: 1, name: 'Impreza WRX'}
Expected behavior
By looking at the document
useLazyQuery
My expected behavior is that on the second time when I click the button, useLazyQuery return a false and we should execute the refetch() as per the document
function fetchOrRefetch () {
load() || refetch()
}
Versions
"vue": "^3.5.12",
"@vue/apollo-composable": "4.2.1",
"@apollo/client": "^3.11.8",
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
No labels