Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
subscription$$ =>
pipe(
subscription$$,
switchMap(subscription$ => {
if (!subscription$) return fromValue({ fetching: false });
return concat([
// Initially set fetching to true
fromValue({ fetching: true }),
pipe(
subscription$,
map(({ stale, data, error, extensions }) => ({
fetching: true,
stale: !!stale,
data,
error,
extensions,
}))
),
// When the source proactively closes, fetching is set to false
query$$ =>
pipe(
query$$,
switchMap(query$ => {
if (!query$) return fromValue({ fetching: false });
return concat([
// Initially set fetching to true
fromValue({ fetching: true }),
pipe(
query$,
map(({ stale, data, error, extensions }) => ({
fetching: false,
stale: !!stale,
data,
error,
extensions,
}))
),
// When the source proactively closes, fetching is set to false
executeQuery = <data>(
query: GraphQLRequest,
opts?: Partial
): Source> => {
const operation = this.createRequestOperation('query', query, opts);
const response$ = this.executeRequestOperation(operation);
const { pollInterval } = operation.context;
if (pollInterval) {
return pipe(
merge([fromValue(0), interval(pollInterval)]),
switchMap(() => response$)
);
}
return response$;
};
</data>