-
Notifications
You must be signed in to change notification settings - Fork 108
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
Replace custom ApolloContext with official one #131
Comments
It's not exposed in the cjs and esm builds: https://unpkg.com/[email protected]/react-apollo.cjs.js. |
I'd be willing to prepare a PR but I'm not sure how would you like to proceed. Introduce a breaking change and completely deprecate the I would prefer to remove support for the custom context, but I see how people may like to use @trojanowski what's your opinion? |
Well, I think we can just utilize ApolloContext instead of a custom one. And the provider from this package should yield a deprecation warning and use |
So:
(isn't the peerDependency a breaking change nonetheless?) |
Actually, I've managed to migrate the app to hooks so I've dropped the I guess it would need to safely detect if |
Doing |
Yea, that's the tricky part. Sadly I am not aware of any safe way of doing that. I do remember seeing a trick like this but never tried if it actually works.
Perhaps it's not such a good idea doing this after all. I mean this package eventually will be merged to the official one. We just need to be patient. |
Alternatively we could make |
I suppose that would work, but it feels like excessive dependency just to be there just for such a little piece of information. I don't know, I feel it's not such a big deal in the end to have two providers. Initially, I made myself this piece of code to abstract such a detail away. import { ApolloProvider as ApolloProviderHooked, useApolloClient } from '@speedlo/react-apollo-hooks'
import React from 'react'
import { ApolloProvider as ApolloProviderOrig, ApolloProviderProps } from 'react-apollo'
export function ApolloProvider<TCache>({
client,
children,
}: ApolloProviderProps<TCache>) {
return (
<ApolloProviderOrig<TCache> client={client}>
<ApolloProviderHooked<TCache> client={client}>
{children}
</ApolloProviderHooked>
</ApolloProviderOrig>
)
}
export { useApolloClient } |
It's not a big deal, but people get easily scared by it. In my team I received concerns from several team members because of that provider, they think this library tries to replace Apollo completely. I know it's not this library's fault, but it's something that could be easily avoided if the README told the users this library can be used in their current |
Honestly, if someone is not using Let's some other people chime in on this or you can prepare some preliminary PR and we can go from there. |
I agree with @FredyC. It's often possible to replace all HOCs / render props with hooks (or just start with hooks and don't use alternative APIs at all, e.g. in new projects). And after that, it's easier to install only one library, instead of two. And if you want to use react-apollo and react-apollo-hooks together, the integration is quite simple. @FezVrasta if you don't agree with that maybe a better idea will be to improve the documentation? |
I think the documentation is fine, it's just the developer experience that lacks |
I use both react-apollo and react-apollo-hooks, I probably won't ever just use react-apollo-hooks on it's own. So a dependency on react-apollo to reduce the provider duplication wouldn't hurt me. For context, so far I am using |
@dantman For conditional querying, I made my own |
Starting from [email protected] we have access to the ApolloContext (https://unpkg.com/[email protected]/ApolloContext.js).
This would enable this library to get rid of the custom
ApolloProvider
andApolloContext
and just rely onreact-apollo
The text was updated successfully, but these errors were encountered: