-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
How to have multi clients ? #90
Comments
This lib saves the client to the svelte context so you can have multiple wrapper components and each one can have a different client Example <script lang='ts'>
import { ApolloClient, InMemoryCache } from '@apollo/client/core';
import { setClient } from 'svelte-apollo';
const client = new ApolloClient({
cache: new InMemoryCache()
});
setClient(client);
</script>
<slot /> <ApolloProvider>
Components...
</ApolloProvider> You can probably even pass the options to ApolloProvider to configure the client |
@unlocomqx I don't think you have answered the question. Your example shows one client. I can read between the lines though when you say "you can have multiple wrapper components and each one can have a different client", you mean sibling components. So half your app's components that are children of one provider can use that client, while the other half that are children of the second provider can use that client. You apparently cannot use multiple clients in a single child component, precisely because the library chose to implement as a single key on context. What I mean is, you cannot wrap your app as follows
With the expectation that You also couldn't use In order to "support multi client" the library would need to allow you to pass in the keyname for context so that you could have "client1" and "client2" both be consumable context simultaneously on a child component. Or pass an object with multiple keys, etc. If you can come up with an example where one child component can make queries from more than one provider, please do share and prove me wrong! |
How to pass more than 1 Apollo clients ?
I haven't tried this package but went through the document and wondering how to pass multi clients
The text was updated successfully, but these errors were encountered: