Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

ApolloProvider #36

Merged
merged 19 commits into from
May 3, 2016
Merged

ApolloProvider #36

merged 19 commits into from
May 3, 2016

Conversation

abhiaiyer91
Copy link
Contributor

@abhiaiyer91 abhiaiyer91 commented Apr 29, 2016

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 to ApolloProvider, and uses react-redux provider. Added some more tests too.

@abhiaiyer91
Copy link
Contributor Author

Man, Test coverage went down lol. wth

@abhiaiyer91
Copy link
Contributor Author

How shall the version bump go?

@stubailo
Copy link
Contributor

@abhiaiyer91 sigh, coveralls is really unreliable.

Let's bump the version after merging!

@abhiaiyer91
Copy link
Contributor Author

@stubailo I made a mistake and also grouped the namespace change as well!

@abhiaiyer91
Copy link
Contributor Author

@stubailo @jbaxleyiii sorry for mixing in the namespace change with this body of work. I can reopen 2 PRs if necessary! Let me know!

@abhiaiyer91
Copy link
Contributor Author

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 react-apollo

@jbaxleyiii
Copy link
Contributor

The docs would be great and mention this PR

@stubailo
Copy link
Contributor

NP, one PR is fine!

@abhiaiyer91
Copy link
Contributor Author

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 */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be removed.

@jbaxleyiii
Copy link
Contributor

👍 I'll take a look tonight

@abhiaiyer91
Copy link
Contributor Author

@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> {
Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor

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>
      ...

Copy link
Contributor Author

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.

@abhiaiyer91
Copy link
Contributor Author

Thanks for the feedback, will iterate again!

@stubailo
Copy link
Contributor

stubailo commented May 2, 2016

Thanks - I'm going to try to get you that architectural overview ASAP

@abhiaiyer91 abhiaiyer91 changed the title composeApolloProvider ApolloProvider May 3, 2016
@abhiaiyer91
Copy link
Contributor Author

@stubailo @jbaxleyiii i think this is good to go!

@@ -0,0 +1,97 @@
/// <reference path="../typings/main.d.ts" />
Copy link
Contributor

@stubailo stubailo May 3, 2016

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shit man sorry!

@jbaxleyiii
Copy link
Contributor

@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

@stubailo
Copy link
Contributor

stubailo commented May 3, 2016

I think we need a corresponding docs PR before merging.

@stubailo
Copy link
Contributor

stubailo commented May 3, 2016

Also, this PR changes everything from 2-space tabs to 4-space tabs, which isn't great.

@jbaxleyiii
Copy link
Contributor

I didn't catch that. I'm surprised the linter didnt bug out. Let's fix that

@abhiaiyer91
Copy link
Contributor Author

I just noticed. WebStorm messing with me...

@abhiaiyer91
Copy link
Contributor Author

Let me fix!

@stubailo
Copy link
Contributor

stubailo commented May 3, 2016

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>;
Copy link
Contributor

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.

@abhiaiyer91
Copy link
Contributor Author

Alright Editor is all setup! Hahah my bad. I hit the "Typescript" button in WebStorm, turns out my settings were F'd up.

@stubailo
Copy link
Contributor

stubailo commented May 3, 2016

Feel free to commit in a WebStorm config! We have one for vscode in the repo.

@stubailo
Copy link
Contributor

stubailo commented May 3, 2016

Looks great to me!

Last step is the docs PR, then we can merge and publish!

@abhiaiyer91
Copy link
Contributor Author

Okay I'll get the docs PR together now.

@abhiaiyer91
Copy link
Contributor Author

@stubailo
Copy link
Contributor

stubailo commented May 3, 2016

OK, up to @jbaxleyiii to merge and publish this and the docs change at the same time!

@jbaxleyiii jbaxleyiii merged commit b292fae into apollographql:master May 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants