Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update zen-observable-ts to eliminate transitive dependency on @types/zen-observable #8695

Merged
merged 3 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
- Calling `refetch` on a skipped query will have no effect (issue [#8270](https://github.com/apollographql/apollo-client/issues/8270)).
- Prevent `onError` and `onCompleted` functions from firing continuously, and improving their polling behavior.

### Other Bugs Fixed

- Update `zen-observable-ts` to eliminate transitive dependency on `@types/zen-observable`. <br/>
[@benjamn](https://github.com/benjamn) in [#8695](https://github.com/apollographql/apollo-client/pull/8695)

## Apollo Client 3.4.9 (not yet released)

### Bug Fixes
Expand Down
26 changes: 7 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"symbol-observable": "^4.0.0",
"ts-invariant": "^0.9.0",
"tslib": "^2.3.0",
"zen-observable-ts": "^1.1.0"
"zen-observable-ts": "^1.2.0"
},
"devDependencies": {
"@babel/parser": "7.15.3",
Expand Down
6 changes: 3 additions & 3 deletions src/core/__tests__/QueryManager/links.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// externals
import gql from 'graphql-tag';

import { Observable } from '../../../utilities/observables/Observable';
import { Observable, ObservableSubscription } from '../../../utilities/observables/Observable';
import { ApolloLink } from '../../../link/core';
import { InMemoryCache } from '../../../cache/inmemory/inMemoryCache';

Expand Down Expand Up @@ -104,7 +104,7 @@ describe('Link interactions', () => {
});

let count = 0;
let four: ZenObservable.Subscription;
let four: ObservableSubscription;
// first watch
const one = observable.subscribe(result => count++);
// second watch
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('Link interactions', () => {
});

let count = 0;
let four: ZenObservable.Subscription;
let four: ObservableSubscription;
// first watch
const one = observable.subscribe(result => count++);
// second watch
Expand Down
6 changes: 5 additions & 1 deletion src/core/__tests__/QueryManager/recycler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
// core
import { QueryManager } from '../../QueryManager';
import { ObservableQuery } from '../../ObservableQuery';
import { ObservableSubscription } from '../../../utilities';

describe('Subscription lifecycles', () => {
it('cleans up and reuses data like QueryRecycler wants', done => {
Expand Down Expand Up @@ -48,7 +49,10 @@ describe('Subscription lifecycles', () => {
fetchPolicy: 'cache-and-network',
});

const observableQueries: { observableQuery: ObservableQuery, subscription: ZenObservable.Subscription; }[] = [];
const observableQueries: Array<{
observableQuery: ObservableQuery;
subscription: ObservableSubscription;
}> = [];

const resubscribe = () => {
const { observableQuery, subscription } = observableQueries.pop()!;
Expand Down
4 changes: 2 additions & 2 deletions src/link/context/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApolloLink, Operation, GraphQLRequest, NextLink } from '../core';
import { Observable } from '../../utilities';
import { Observable, ObservableSubscription } from '../../utilities';

export type ContextSetter = (
operation: GraphQLRequest,
Expand All @@ -11,7 +11,7 @@ export function setContext(setter: ContextSetter): ApolloLink {
const { ...request } = operation;

return new Observable(observer => {
let handle: ZenObservable.Subscription;
let handle: ObservableSubscription;
let closed = false;
Promise.resolve(request)
.then(req => setter(req, operation.getContext()))
Expand Down
4 changes: 2 additions & 2 deletions src/link/core/ApolloLink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InvariantError, invariant } from 'ts-invariant';

import { Observable } from '../../utilities';
import { Observable, Observer } from '../../utilities';
import {
NextLink,
Operation,
Expand Down Expand Up @@ -143,7 +143,7 @@ export class ApolloLink {

protected onError(
error: any,
observer?: ZenObservable.Observer<FetchResult>,
observer?: Observer<FetchResult>,
): false | void {
if (observer && observer.error) {
observer.error(error);
Expand Down
6 changes: 3 additions & 3 deletions src/link/http/__tests__/HttpLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gql from 'graphql-tag';
import fetchMock from 'fetch-mock';
import { print } from 'graphql';

import { Observable } from '../../../utilities/observables/Observable';
import { Observable, Observer, ObservableSubscription } from '../../../utilities/observables/Observable';
import { ApolloLink } from '../../core/ApolloLink';
import { execute } from '../../core/execute';
import { HttpLink } from '../HttpLink';
Expand Down Expand Up @@ -53,8 +53,8 @@ describe('HttpLink', () => {
const data = { data: { hello: 'world' } };
const data2 = { data: { hello: 'everyone' } };
const mockError = { throws: new TypeError('mock me') };
let subscriber: ZenObservable.Observer<any>;
const subscriptions = new Set<ZenObservable.Subscription>();
let subscriber: Observer<any>;
const subscriptions = new Set<ObservableSubscription>();

beforeEach(() => {
fetchMock.restore();
Expand Down
9 changes: 7 additions & 2 deletions src/link/persisted-queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import {
import { invariant } from 'ts-invariant';

import { ApolloLink, Operation } from '../core';
import { Observable, Observer, compact } from '../../utilities';
import {
Observable,
Observer,
ObservableSubscription,
compact,
} from '../../utilities';

export const VERSION = 1;

Expand Down Expand Up @@ -147,7 +152,7 @@ export const createPersistedQueryLink = (
const { query } = operation;

return new Observable((observer: Observer<ExecutionResult>) => {
let subscription: ZenObservable.Subscription;
let subscription: ObservableSubscription;
let retried = false;
let originalFetchOptions: any;
let setFetchOptions = false;
Expand Down
10 changes: 5 additions & 5 deletions src/link/retry/retryLink.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApolloLink, Operation, FetchResult, NextLink } from '../core';
import { Observable } from '../../utilities';
import { Observable, Observer, ObservableSubscription } from '../../utilities';
import {
DelayFunction,
DelayFunctionOptions,
Expand Down Expand Up @@ -34,8 +34,8 @@ class RetryableOperation<TValue = any> {
private error: any;
private complete = false;
private canceled = false;
private observers: (ZenObservable.Observer<TValue> | null)[] = [];
private currentSubscription: ZenObservable.Subscription | null = null;
private observers: (Observer<TValue> | null)[] = [];
private currentSubscription: ObservableSubscription | null = null;
private timerId: number | undefined;

constructor(
Expand All @@ -51,7 +51,7 @@ class RetryableOperation<TValue = any> {
* If the operation has previously emitted other events, they will be
* immediately triggered for the observer.
*/
public subscribe(observer: ZenObservable.Observer<TValue>) {
public subscribe(observer: Observer<TValue>) {
if (this.canceled) {
throw new Error(
`Subscribing to a retryable link that was canceled is not supported`,
Expand All @@ -77,7 +77,7 @@ class RetryableOperation<TValue = any> {
* If no observers remain, the operation will stop retrying, and unsubscribe
* from its downstream link.
*/
public unsubscribe(observer: ZenObservable.Observer<TValue>) {
public unsubscribe(observer: Observer<TValue>) {
const index = this.observers.indexOf(observer);
if (index < 0) {
throw new Error(
Expand Down
4 changes: 2 additions & 2 deletions src/react/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReactNode } from 'react';
import { DocumentNode } from 'graphql';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';

import { Observable } from '../../utilities';
import { Observable, ObservableSubscription } from '../../utilities';
import { FetchResult } from '../../link/core';
import { ApolloError } from '../../errors';
import {
Expand Down Expand Up @@ -239,5 +239,5 @@ export interface SubscriptionDataOptions<

export interface SubscriptionCurrentObservable {
query?: Observable<any>;
subscription?: ZenObservable.Subscription;
subscription?: ObservableSubscription;
}