-
Notifications
You must be signed in to change notification settings - Fork 787
Conversation
ApolloProvider wrapper Component
Enable Tests, and work around odd TS.
Apollo Provider tests and touch up
Compose an ApolloProvider
add test for store context
Man, Test coverage went down lol. wth |
How shall the version bump go? |
@abhiaiyer91 sigh, coveralls is really unreliable. Let's bump the version after merging! |
@stubailo I made a mistake and also grouped the namespace change as well! |
@stubailo @jbaxleyiii sorry for mixing in the namespace change with this body of work. I can reopen 2 PRs if necessary! Let me know! |
change Provider namespace to ApolloProvider
We should also rewrite the docs and example apps with new Namespace if merged. And add a section for the composable provider. Would you like an issue opened in the docs or here in |
The docs would be great and mention this PR |
NP, one PR is fine! |
Alright issues made. Whenever you guys get a chance to give some feedback, that'd be great! Once merged @stubailo assign the issue in the docs to me! |
@@ -0,0 +1,72 @@ | |||
/// <reference path="../typings/main.d.ts" /> | |||
/* tslint:disable:no-unused-variable */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be removed.
👍 I'll take a look tonight |
@jbaxleyiii @stubailo show this PR some love! haha |
@@ -17,7 +17,7 @@ export declare interface ProviderProps { | |||
client: ApolloClient; | |||
} | |||
|
|||
export default class Provider extends Component<ProviderProps, any> { | |||
export default class ApolloProvider extends Component<ProviderProps, any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the file, as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, shouldn't ApolloProvider
just use composeApolloProvider
under the hood now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah those are the kinda questions I wanted to talk through. Since we added some duplication with this function.
I think ApolloProvider
should be shipped using composeApolloProvider
under the hood.
client: ApolloClient; | ||
} | ||
|
||
export default function composeApolloProvider<T>(Provider: React.ComponentClass<any>): any { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this function better than simply having ApolloProvider
always use Provider
as the implementation? As long as it's a peer dependency, the developer can choose whatever version of the Redux provider they feel like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I feel like it just adds an extra line of code, but doesn't really add much clarity since you still don't know what it's doing with the Provider
. If we wanted people to have the ultimate clarity about what the provider is doing we could just ask them to use two providers:
<Provider>
<ApolloProvider>
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think now that we are actually using Redux under the hood for the provider, we should just recommend people use this directly. Now that my feet are more wet into Apollo, I think using the ApolloProvider directly with this implementation makes more sense, than composing it yourself in app.
Thanks for the feedback, will iterate again! |
Thanks - I'm going to try to get you that architectural overview ASAP |
@stubailo @jbaxleyiii i think this is good to go! |
@@ -0,0 +1,97 @@ | |||
/// <reference path="../typings/main.d.ts" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in this file name! (ApolloProivder)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shit man sorry!
@abhiaiyer91 @stubailo I'm good with this! We will need to update docs and the Changelog. I'll publish it as v0.3.0 after we merge |
I think we need a corresponding docs PR before merging. |
Also, this PR changes everything from 2-space tabs to 4-space tabs, which isn't great. |
I didn't catch that. I'm surprised the linter didnt bug out. Let's fix that |
I just noticed. WebStorm messing with me... |
Let me fix! |
I think about a year ago all of the linters collectively gave up on linting whitespace since there are so many edge cases. but maybe it's possible. I don't think any linter can save us from inspecting the code :] |
@@ -33,8 +38,8 @@ export default class Provider extends Component<ProviderProps, any> { | |||
client: PropTypes.object.isRequired, | |||
}; | |||
|
|||
public store: Store<any>; | |||
public client: ApolloClient; | |||
public store:Store<any>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have a space, I thought TSLint enforced this. @abhiaiyer91 you might want to set up TSLint in your editor.
Alright Editor is all setup! Hahah my bad. I hit the "Typescript" button in WebStorm, turns out my settings were F'd up. |
Feel free to commit in a WebStorm config! We have one for vscode in the repo. |
Looks great to me! Last step is the docs PR, then we can merge and publish! |
Okay I'll get the docs PR together now. |
OK, up to @jbaxleyiii to merge and publish this and the docs change at the same time! |
After much iteration, the best way to interact with the redux provider is through a wrapper component. We ended up changing the namespace of
Provider
toApolloProvider
, and usesreact-redux
provider. Added some more tests too.