UNPKG

apollo-angular

Version:

Use your GraphQL data in your Angular app, with the Apollo Client

42 lines (41 loc) 1.69 kB
import { type OperatorFunction } from 'rxjs'; import type { ApolloClient, GetDataState, ObservableQuery } from '@apollo/client/core'; type CompleteFragment<TData> = { complete: true; missing?: never; } & GetDataState<TData, 'complete'>; type ForWatchFragment<TData> = OperatorFunction<ApolloClient.WatchFragmentResult<TData>, CompleteFragment<TData>>; /** * Filter emitted results to only receive results that are complete (`result.dataState === 'complete'`). * * This is a small wrapper around rxjs `filter()` for convenience only. * * If you use this, you should probably combine it with [`notifyOnNetworkStatusChange`](https://www.apollographql.com/docs/react/data/queries#queryhookoptions-interface-notifyonnetworkstatuschange). * This tells `@apollo/client` to not emit the first `partial` result, so `apollo-angular` does * not need to filter it out. The overall behavior is identical, but it saves some CPU cycles. * * So something like this: * * ```ts * apollo * .watchQuery({ * query: myQuery, * notifyOnNetworkStatusChange: false, // Adding this will save CPU cycles * }) * .valueChanges * .pipe(onlyCompleteData()) * .subscribe(result => { * // Do something with complete result * }); * ``` */ export declare function onlyCompleteData<TData>(): OperatorFunction<ObservableQuery.Result<TData>, ObservableQuery.Result<TData, 'complete'>>; /** * @deprecated Use `onlyCompleteData()` instead. */ export declare const onlyComplete: typeof onlyCompleteData; /** * Same as `onlyCompleteData()` but for `Apollo.watchFragment()`. */ export declare function onlyCompleteFragment<TData>(): ForWatchFragment<TData>; export {};