Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 315d4be6c7 | |||
| f4c56afb53 | |||
| 31657ada67 | |||
| d19a090df2 |
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "@vue/apollo-composable",
|
||||
"version": "4.0.0-beta.1",
|
||||
"name": "@speckle/vue-apollo-composable",
|
||||
"version": "4.0.0-beta.2",
|
||||
"description": "Apollo GraphQL for Vue Composition API",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vuejs/vue-apollo.git",
|
||||
"url": "https://github.com/specklesystems/apollo.git",
|
||||
"directory": "packages/vue-apollo-composable"
|
||||
},
|
||||
"keywords": [
|
||||
@@ -32,7 +32,7 @@
|
||||
"dev": "rimraf dist && nodemon --exec 'pnpm run build:code' --watch src --ext js,ts",
|
||||
"build": "rimraf dist && pnpm run build:code",
|
||||
"build:code": "node esbuild.mjs && tsc -d --emitDeclarationOnly",
|
||||
"prepublishOnly": "pnpm run test && pnpm run build",
|
||||
"prepublishOnly": "pnpm run test && pnpm run build:code",
|
||||
"test": "pnpm run test:types",
|
||||
"test:types": "tsc -p tests/types/"
|
||||
},
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
ObservableSubscription,
|
||||
TypedDocumentNode,
|
||||
ApolloError,
|
||||
NetworkStatus
|
||||
} from '@apollo/client/core'
|
||||
import { throttle, debounce } from 'throttle-debounce'
|
||||
import { useApolloClient } from './useApolloClient'
|
||||
@@ -221,6 +222,7 @@ export function useQueryImpl<
|
||||
const query: Ref<ObservableQuery<TResult, TVariables> | null | undefined> = ref()
|
||||
let observer: ObservableSubscription | undefined
|
||||
let started = false
|
||||
let isFirstRun = true
|
||||
|
||||
/**
|
||||
* Starts watching the query
|
||||
@@ -258,12 +260,26 @@ export function useQueryImpl<
|
||||
addSubscribeToMore(item)
|
||||
}
|
||||
}
|
||||
|
||||
isFirstRun = false
|
||||
}
|
||||
|
||||
function startQuerySubscription () {
|
||||
if (observer && !observer.closed) return
|
||||
if (!query.value) return
|
||||
|
||||
// If hydrating already finished queries, just handle result immediately
|
||||
if (!isServer && isFirstRun) {
|
||||
const currentResult = query.value.getCurrentResult()
|
||||
if (currentResult) {
|
||||
if (currentResult.networkStatus === NetworkStatus.ready) {
|
||||
onNextResult(currentResult)
|
||||
} else if (currentResult.networkStatus === NetworkStatus.error && currentResult.error) {
|
||||
onError(currentResult.error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create subscription
|
||||
observer = query.value.subscribe({
|
||||
next: onNextResult,
|
||||
|
||||
Reference in New Issue
Block a user