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

ApolloProvider #35

Closed
wants to merge 6 commits into from
Closed

ApolloProvider #35

wants to merge 6 commits into from

Conversation

abhiaiyer91
Copy link
Contributor

In reference to this issue #142
This PR is the first step of providing Apollo users a direct integration with the Redux library and set of existing tools.

What are we shipping?

I think to provide a seamless integration into current Redux workflows, exporting an ApolloProvider allows us to maintain the Apollo integration a layer above ReactRedux's Provider implementation.

Usage

import React from 'react';
import { render } from 'react-dom';
import { ApolloProvider } from 'react-apollo';
import Store from './store';
import ApolloClient from 'apollo-client';

const client = new ApolloClient();

Meteor.startup(() => {
  render(<ApolloProvider store={Store} client={client}>
    <App />
  </ApolloProvider>, document.getElementById('app'));
});

To note: store is a required prop

Benefits

On the surface this change doesn't seem like a big deal. And really it isn't far off then what react-apollo ships, but:

  1. this allows react-apollo to gain upstream changes to the Provider component from react-redux. 2. helps alleviate confusion between large apps that may be fragmented, meaning they don't have clear component trees e.g. multiple Providers who may be confused what Provider they are actually using. People don't read 馃毃

@@ -0,0 +1,60 @@
/// <reference path="../typings/main.d.ts" />
/* tslint:disable:no-unused-variable */
import * as React from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

weird errors in compile. Anyone know what this is all about? Had to do this to appease Provider

@stubailo
Copy link
Contributor

Yeah I think something as simple as changing the export name can be good to avoid confusion between the two.

@jbaxleyiii
Copy link
Contributor

@abhiaiyer91 I'm not a fan of having to pass a store. It locks us into redux (which I like redux fwiw) and exposing an internal part of the client (that is exposed for advanced reasons) adds a barrier to usage in my opinion.

@abhiaiyer91
Copy link
Contributor Author

@jbaxleyiii I agree with you, but this component is strictly for Redux implementation no? Unless we want to use this at the forefront, then what I'll do is make it behave like the current react-apollo Provider no problems!

@jbaxleyiii
Copy link
Contributor

@abhiaiyer91 ah I see, this wouldnt be the most commonly used provider.

One thing I was wondering about is composing with react-redux provider for ours and exposing that composition method so people already using provider wouldn't need to replace, just compose the Apollo addition

That way there is only one provider for clarity but we still get the benefits mentioned above.

Thoughts?

@abhiaiyer91
Copy link
Contributor Author

I am down with that @jbaxleyiii. That will be a lot cleaner. What do you think @stubailo

I'll close this PR and make that happen.

@jbaxleyiii
Copy link
Contributor

@abhiaiyer91 awesome! Thanks!

@stubailo
Copy link
Contributor

Great idea! But I still think we could rename Provider to ApolloProvider - what do you think?

@abhiaiyer91
Copy link
Contributor Author

Yeah I'll do that in another PR

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.

None yet

3 participants