question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Separating networkInterface logic and implementation in favor of supporting more network interface types

See original GitHub issue

(Continuation of #749)

So Generally, my finally goal, is to be able support more then just HTTP for apollo-client, starting with websocket in the near term and maybe HTTP2 in the future.

So, IMO we need separate networkInterface generic/common logic (such as middlewares/batching) from the implementation logic (Http fetch in that case). to do that, the following steps should be taken:

  1. Make middleware/afterware generic (GraphQL and not networkInterface)
    • Suggested interface:

      export interface ResponseAndOptions {
              interfaceType: string;      // string indicating which transport layer is used.
                                                      // afterware might treat response differently depends on that.
              result: GraphQLResult;  // GraphQL parsed response
              response: IResponse;    // GraphQL raw response. (Optional, depends on interfaceType)
              options: RequestInit;
      }
      

      NOTE: if the transport layer response is sent to middleware, then middlewares should be able to support errors chain as well. (next(err) should work), else, what/how would you like it to validate?

  2. separate the logics (I have a draft which i still need to work on, but now i got one step back), which means:
    • common networkInterface logic will reside in genericNetworkInterface abstract class which will provide an abstract protected/public method to do the network specific operations.
      • for example, HTTPFetchNetworkInterface will inherint the genericNetworkInterface, and then implement just one function which will send the actual fetch.
    • batched interface will become abstract as well and will extend genericNetworkInterface to provide abstracted batching logic.
    • Another class (HTPPFetchBatchedNetworkInterface) will inherit batchedNetworkInterface and implement the same exact fetch as above.

from this point, i believe that adding more and more networkInterfaces will be easier as it is much more generic and all that needs to be done to add an interface is to provide 1 function. also, IMO, this approach will make it easier in the future to release networkInterfaces as different small packages.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stubailocommented, Jul 31, 2017
0reactions
stale[bot]commented, Jul 29, 2017

This issue has been automatically closed because it has not had recent activity after being marked as stale. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to Apollo Client!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best Practices for Using Multiple Network Interfaces (NICs ...
Rule 1: Be Careful About Automatic IP Assignment (via DHCP or link-local addressing) Most OSs are configured by default to obtain TCP/IP ...
Read more >
Introduction to Linux interfaces for virtual networking
In this post, I will give a brief introduction to all commonly used virtual network interface types. There is no code analysis, only...
Read more >
Elastic network interfaces - Amazon Elastic Compute Cloud
Instance type Maximum network interfaces Private IPv4 addresses per interface IPv6 addre... a1.medium 2 4 4 a1.large 3 10 10 a1.xlarge 4 15 15
Read more >
About Network Modes and Interfaces
A primary component of your Firebox setup is the configuration of network interface IP addresses. When you run the Web Setup Wizard or...
Read more >
Configuring Virtual Interfaces - Cisco
The null interface is a virtual network interface that is similar to the loopback interface. Whereas traffic to the loopback interface is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found