jaydenseric / graphql-react

A GraphQL client for React using modern context and hooks APIs that is lightweight (< 4 kB) but powerful; the first Relay and Apollo alternative with server side rendering.
https://npm.im/graphql-react
MIT License
718 stars 22 forks source link

GraphQLQuery not exported #9

Closed malixsys closed 6 years ago

malixsys commented 6 years ago

Please export GraphQLQuery so the library can be used with React 15 and react-broadcast?

https://github.com/jaydenseric/graphql-react/blob/fafa8b6f4c02d9c77a70e6da421ec6ff53f2313f/src/components.mjs#L78

jaydenseric commented 6 years ago

Thanks for the suggestion!

I'm not sure that is the best way forward though...

Once React Suspense is available we'll take advantage of it too, and the react peer dep will be raised accordingly.

A better solution might be to update React for your webapp, which in many cases is fairly straightforward. Is that something that is doable?

jaydenseric commented 6 years ago

It's not a good idea to support different versions of React for each part of the API. GraphQLQuery happens work for you in right now in React v15 by dumb luck, other parts of the API will definitely not work.

To officially support React v15 would mean shifting the peer dep down (or you'll get peer dep warnings on npm install), polyfilling the context API (bundle size hit for all consumers), adding tests for React v15, etc. and I will have to avoid using modern component lifecycle hooks, which will lead to a worse product in the long run.

Data fetching is a critical part of a webapp. Most people begin using graphql-react at the start of their project, and most people start new projects with a current version of React.

Regarding the question if it's possible to update React in your existing project,

Ok sorry, but that doesn’t work IRL.

I was hoping for something a little more specific to inform the discussion 😐

You'll find it increasingly difficult over time to fork every library built for modern React; it won't always be as easy as adding 7 "missing" characters.