Skip to content

Remove networkInterface for ApolloLink - #1993

Merged
jbaxleyiii merged 16 commits into
2.0-alphafrom
link-only
Aug 10, 2017
Merged

jbaxleyiii merged 16 commits into
2.0-alphafrom
link-only

Conversation

@jbaxleyiii

@jbaxleyiii jbaxleyiii commented Aug 3, 2017 •

Copy link
Copy Markdown
Contributor

This PR removes the current transport stack (networkInterface, batched, etc) in favor of supporting the first run of ApolloLink. It is focused on adjustments to query manager and associated tests.

This PR does not support returning multiple results from a link. That will be in a follow up PR.

Checklist:

  • Make sure all of the significant new logic is covered by tests
  • Update subscription method

Breaking Changes:

  • Previously, subscription transport could have a client side error, and still receive data through the observable. This isn't spec compliant as observer.error should set closed to true on the observer prevent further calling. This test shows an error happening, then observer.next getting information and passing it through to updateQuery

cc @evanshauser

@mention-bot

Copy link
Copy Markdown

@jbaxleyiii, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Poincare, @helfer and @lewisf to be potential reviewers.

@evans evans left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Couple changes for Deduplicator and then we should be good to go!

this.networkInterface = networkInterface;
this.deduplicator = new Deduplicator(networkInterface);
this.link = link;
this.deduplicator = new Deduplicator(link);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deduplicator should accept an Apollo Link. Could be this PR or next

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evanshauser so I totally had it locally and forgot to commit it haha

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would moving the deduplicator into a Link be part of 2.0? It seems pretty decoupled so it might be easy.

*/
public subscribe(options: SubscriptionOptions): Observable<any> {
this.initQueryManager();
// public subscribe(options: SubscriptionOptions): Observable<any> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flag

}
};
}
// public subscribeToMore(options: SubscribeToMoreOptions): () => void {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flag

this.networkInterface = networkInterface;
this.deduplicator = new Deduplicator(networkInterface);
this.link = link;
this.deduplicator = new Deduplicator(link);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would moving the deduplicator into a Link be part of 2.0? It seems pretty decoupled so it might be easy.

.then(result => {
const observable = execute(this.link, request);
return new Promise((resolve, reject) => {
makePromise(observable)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just return this promise directly instead of wrapping in new Promise?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its for the nested reject state to capture errors and pass them to catch. I think we should change this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, flag for discussion then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stubailo I'm going to implement the new error portion on a follow up PR

} as Subscription;
});
}
// public startGraphQLSubscription(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flag

use(middlewares: NetworkMiddleware): HTTPNetworkInterface,
useAfter(afterwares: NetworkAfterware): HTTPNetworkInterface,
query(request: Request): Promise<ExecutionResult>
query(request: Request): Promise<ExecutionResult>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is odd - do we have misconfigured Prettier somewhere? It's a good change, but seems to be a configuration smell

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, yeah thats odd

// Turn off warnings for repeated fragment names
graphqlTagDisableFragmentWarnings();

import './ApolloClient';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol these are alphabetized now? Did you do that manually or is there some tool?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vscode cmd + shift + p; sort lines

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

legit

Comment thread packages/apollo-link-core/src/types.ts Outdated
query: DocumentNode;
variables?: Record<string, any>;
operationName?: string;
operationName?: string | null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the ? already cover null?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope! its undefined | string instead of undefined | string | null

@jbaxleyiii

Copy link
Copy Markdown
Contributor Author

Lerna / npm / WSL is giving me problems and its past 1 here so I'm going to finish this in the morning

@apollo-cla

apollo-cla commented Aug 4, 2017 •

Copy link
Copy Markdown
Warnings
⚠️

❗ Big PR

Messages
📖

Please add your name and email to the AUTHORS file (optional)

📖

If this was a change that affects the external API, please update the docs and post a link to the PR in the discussion

Generated by 🚫 dangerJS

@jbaxleyiii jbaxleyiii changed the title [WIP] Remove networkInterface for ApolloLink Remove networkInterface for ApolloLink Aug 4, 2017
@jbaxleyiii

Copy link
Copy Markdown
Contributor Author

@stubailo @evanshauser this is ready for another look but evans and I just realized we had our wires crossed on how subscriptions would be changing.

@stubailo I'm not familiar enough with subscriptions, if you have some time would you look this over. The basic idea is to remove the id for subscriptions and return back a full observable of the results.

Comment thread packages/apollo-link-core/src/types.ts Outdated
export type Subscription = ZenObservable.Subscription;
export type Observer<T> = ZenObservable.Observer<T>;
export type Subscriber<T> = ZenObservable.Subscriber<T>;
export type ObservableLike<T> = ZenObservable.ObservableLike<T>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are now exported directly from ZenObservable if it makes sense to use export * from 'zen-observable-tx

Comment thread packages/apollo-link-core/src/types.ts Outdated
@@ -1,6 +1,12 @@
import Observable from 'zen-observable-ts';
import Observable, { ZenObservable } from 'zen-observable-ts';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to include apollo-link in the monorepo?

I think we will eventually want to. Now might be a little premature

@jbaxleyiii
jbaxleyiii merged commit 69fcfcc into 2.0-alpha Aug 10, 2017
@jbaxleyiii
jbaxleyiii deleted the link-only branch August 10, 2017 15:23
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants