apollographql / meteor-integration

🚀 meteor add apollo
http://dev.apollodata.com/core/meteor.html
108 stars 45 forks source link

Custom NetworkInterface for meteorClientConfig #67

Closed ex0ns closed 7 years ago

ex0ns commented 7 years ago

Hi,

I'm currently trying to make PersistedQueryNetworkInterface from https://github.com/apollographql/persistgraphql work with this package, but as mail-client.js uses createNetworkInterface from the apollo-client package, there is no clean way to use another networkInterface.

Why not simply set by hand the NetworkInterface, without using meteorClientConfig ?

Well because meteorClientConfig is very convenient as it adds a middleware to support Meteor User Account, and I don't want to simply copy/paste this middleware into my code.

Do you think such a feature could be useful ? Would you be interested in a PR that enable the user to use a custom NetworkInterface inside meteorClientConfig ?

xavxyz commented 7 years ago

Hey @ex0ns!

That sounds great! I'm working on a PR to allow to use BatchingInterface or classic NetworkInterface (https://github.com/apollographql/meteor-integration/pull/62), maybe we could make it go further by having the availability to choose any kind of interface? 🌟

ex0ns commented 7 years ago

Oh ! Great ! We could indeed try to make it work with any kind of interface. The current implementation is bothering me as adding new interfaces will require adding new options and cases to the createMeteorNetworkInterface method.

I currently don't have a perfect solution, but maybe we could remove some code logic inside the createMeteorNetworkInterface and asking more to the programmer could be a solution, for instance, we could imagine a code like this

export const meteorClientConfig = (networkInterfaceConfig, networkInterfaceConstructor)

Where you could pass createBatchingNetworkInterface or PersistedQueryNetworkInterface as constructor and {batchingInterface: true, batchInterval: 10} as specific parameters for the given interface.

Don't know if this implementation is better, but at least it would be easy to use any kind of interface.

xavxyz commented 7 years ago

Hey @ex0ns!

You can now use any kind of network interface 🎉

const customInterface = ... // persisted one?!

const client = new ApolloClient(meteorClientConfig({ networkInterface: customInterface }));

Let us know if it works well with a PersistedQueryInterface! 💯

It will keep the default client configuration (ssrMode & dataIdFromObject), but not the default network interface configuration object (meteor accounts middleware & cie.). If you have any idea on how to make this better, a pull request is warmly welcomed 😊

lorensr commented 7 years ago

This works on master, but for it to reach atmosphere, we need to update docs and release 0.4.0 On Thu, Feb 23, 2017 at 1:10 PM Xavier Cazalot notifications@github.com wrote:

Hey @ex0ns https://github.com/ex0ns!

You can now use any kind of network interface 🎉

const customInterface = ... // persisted one?! const client = new ApolloClient(meteorClientConfig({ networkInterface: customInterface }));

Let us know if it works well with a PersistedQueryInterface! 💯

It will keep the default client configuration (ssrMode & dataIdFromObject), but not the default network interface configuration object (meteor accounts middleware & cie.). If you have any idea on how to make this better, a pull request is warmly welcomed 😊

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apollographql/meteor-integration/issues/67#issuecomment-282073057, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPVmIhUYVTc8R6bVVDbK3oyf7l0t7xsks5rfcuWgaJpZM4L52bD .

lorensr commented 7 years ago

Released 0.4.0

On Thu, Feb 23, 2017 at 1:39 PM, Loren Sands-Ramshaw lorensr@gmail.com wrote:

This works on master, but for it to reach atmosphere, we need to update docs and release 0.4.0

On Thu, Feb 23, 2017 at 1:10 PM Xavier Cazalot notifications@github.com wrote:

Hey @ex0ns https://github.com/ex0ns!

You can now use any kind of network interface 🎉

const customInterface = ... // persisted one?! const client = new ApolloClient(meteorClientConfig({ networkInterface: customInterface }));

Let us know if it works well with a PersistedQueryInterface! 💯

It will keep the default client configuration (ssrMode & dataIdFromObject), but not the default network interface configuration object (meteor accounts middleware & cie.). If you have any idea on how to make this better, a pull request is warmly welcomed 😊

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apollographql/meteor-integration/issues/67#issuecomment-282073057, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPVmIhUYVTc8R6bVVDbK3oyf7l0t7xsks5rfcuWgaJpZM4L52bD .