Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getCurrentTracking () {
const { appTracking } = getAppTracking()
const currentInstance = getCurrentInstance()
let tracking: LoadingTracking
if (!appTracking.components.has(currentInstance)) {
// Add per-component tracking
appTracking.components.set(currentInstance, tracking = {
queries: ref(0),
mutations: ref(0),
subscriptions: ref(0),
})
// Cleanup
onUnmounted(() => {
appTracking.components.delete(currentInstance)
})
} else {
tracking = appTracking.components.get(currentInstance)
export function useSubscription <
TResult = any,
TVariables = OperationVariables
> (
document: DocumentNode | Ref | ReactiveFunction,
variables: TVariables | Ref | ReactiveFunction = null,
options: UseSubscriptionOptions | Ref> | ReactiveFunction> = null
) {
// Is on server?
const vm = getCurrentInstance()
const isServer = vm.$isServer
if (variables == null) variables = ref()
if (!options) options = {}
const documentRef = paramToRef(document)
const variablesRef = paramToRef(variables)
const optionsRef = paramToReactive(options)
const result = ref()
const resultEvent = useEventHook>()
const error = ref(null)
const errorEvent = useEventHook()
const loading = ref(false)
trackSubscription(loading)
export function getAppTracking () {
const root: any = getCurrentInstance().$root
let appTracking: AppLoadingTracking
if (!root._apolloAppTracking) {
// Add per Vue tracking
appTracking = root._apolloAppTracking = {
queries: ref(0),
mutations: ref(0),
subscriptions: ref(0),
components: new Map(),
}
} else {
appTracking = root._apolloAppTracking
}
return {
appTracking
export function useQuery<
TResult = any,
TVariables = OperationVariables,
TCacheShape = any
> (
document: DocumentNode | Ref | ReactiveFunction,
variables: TVariables | Ref | ReactiveFunction = null,
options: UseQueryOptions | Ref> | ReactiveFunction> = {},
) {
// Is on server?
const vm = getCurrentInstance()
const isServer = vm.$isServer
if (variables == null) variables = ref()
if (options == null) options = {}
const documentRef = paramToRef(document)
const variablesRef = paramToRef(variables)
const optionsRef = paramToReactive(options)
// Result
/**
* Result from the query
*/
const result = ref()
const resultEvent = useEventHook>()
const error = ref(null)
const errorEvent = useEventHook()