Skip to content
This repository has been archived by the owner on Aug 20, 2020. It is now read-only.

createBatchingNetworkInterface #3

Closed
mitjade opened this issue Jan 19, 2017 · 10 comments
Closed

createBatchingNetworkInterface #3

mitjade opened this issue Jan 19, 2017 · 10 comments

Comments

@mitjade
Copy link

mitjade commented Jan 19, 2017

Would this also work with createBatchingNetworkInterface or just createNetworkInterface?

@Poincare
Copy link
Contributor

At the moment, the PersistedQueryNetworkInterface subclasses the HTTPFetchNetworkInterface although it doesn't really have to do this. Would appreciate a PR that has it depend on a generic NetworkInterface instead!

@ramikhalaf
Copy link
Contributor

@Poincare I'd like to take a stab at this, is there a contribution guide I can follow?

@Poincare
Copy link
Contributor

Poincare commented Feb 8, 2017

@ramikhalaf Awesome! There isn't really a contribution guide but, here's basically the equivalent of one for this particular issue:

This is where the network interface is currently implemented. What you probably want to do is replace this class with a method like addPersistedQueries that takes an Apollo Client Network Interface and changes it so that the query IDs are sent instead. Something like this, except that instead of adding two new methods, you want to replace one of the methods within the Apollo Client Network Interface.

Please let me know if the above makes sense - I can answer questions along the way :)

@ramikhalaf
Copy link
Contributor

@Poincare checkout #9 and let me know if theres anything I can make better!

@mitjade
Copy link
Author

mitjade commented Feb 15, 2017

I see #9 was merged. Any chance of releasing this soon, so I can test it out.

@fubhy
Copy link

fubhy commented Feb 16, 2017

Great work. I opened a PR against apollo-client for the last necessary step (passing through the 'id' property on the request object when batching).

apollographql/apollo-client#1302

@Poincare
Copy link
Contributor

@mitjade Will be released tomorrow night - may be coupled with a couple of other small changes.

@fubhy Thanks! Getting batching working with persisted queries would be super cool.

@mitjade
Copy link
Author

mitjade commented Feb 21, 2017

I seen this was now released and am trying to get this to work.
How would one change for example:

      const client = createApolloClient(createBatchingNetworkInterface({
        uri: apiUrl,
        opts: {
          credentials: "same-origin",
          headers: req.headers,
        },
        batchInterval: 20,
      }));

to work with PersistedQueryNetworkInterface ?

However I try to wrap or replace it with PersistedQueryNetworkInterface , I keep getting TypeError: Cannot set property '_uri' of undefined.

I have latest apollo-client 0.8.7 and persistgraphql 0.3.0 packages.

@mitjade
Copy link
Author

mitjade commented Feb 21, 2017

Sorry, missed addPersistedQueries(networkInterface: NetworkInterface, queryMap: OutputMap) that is mentioned in readme.

@mitjade
Copy link
Author

mitjade commented Feb 23, 2017

Was able to test this and it is working. Will close this now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants