Skip to content
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

Support Relay Modern and Apollo out of the box #3873

Closed
gaearon opened this issue Jan 20, 2018 · 12 comments
Closed

Support Relay Modern and Apollo out of the box #3873

gaearon opened this issue Jan 20, 2018 · 12 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented Jan 20, 2018

We have a few separate issues about this but given the huge growth in GraphQL popularity over the year I think it would be sensible to hardcode support both for Apollo and Relay Modern, without a need for extra macros etc. I’m open to proposals about how this should work, and a proof of concept PR.

@wtgtybhertgeghgtwtg
Copy link
Contributor

Can't say much about Relay, but I haven't had to do anything special to get Apollo to work. I think using either implies a server, though, and the documentation for using create-react-app with a server is a little dated.

@iansu
Copy link
Contributor

iansu commented Jan 20, 2018

I've also used Apollo client (version 1 and 2) with create-react-app without ejecting. Some documentation on setting it up could be helpful though.

I haven't used Relay before but now I'm curious to give it a try and see if there are any issues.

@swyxio
Copy link
Contributor

swyxio commented Jan 22, 2018

agree that apollo doesnt need any extra setup at all. Dan could you clarify what you mean by "hardcode support without a need for extra macros"?

@gaearon
Copy link
Contributor Author

gaearon commented Jan 22, 2018

If Apollo works out of the box, what is #1792 about?

@iansu
Copy link
Contributor

iansu commented Jan 22, 2018

That's about importing .graphql files. You can use Apollo with tagged template literals in your components but you can't put your queries in external files because we don't provide a loader for them. That seems like a good, and relatively easy, thing to add support for.

@gaearon
Copy link
Contributor Author

gaearon commented Jan 22, 2018

Do Relay Modern and Apollo compile GraphQL to the same intermediate representation? I’m just trying to understand if, by implementing this, we’d hardcode support for Apollo, or it would just be a GraphQL thing.

@iansu
Copy link
Contributor

iansu commented Jan 22, 2018

I believe they are both based on and use graphql-js https://github.com/graphql/graphql-js so they should be compatible. In this case I think the webpack loader would just provide the contents of the graphql file which would then be passed to either client (Relay or Apollo) to be compiled, etc.

This is based on my experience with Apollo. It's possible that Relay is completely different but I don't think that's the case.

@petetnt
Copy link
Contributor

petetnt commented Jan 22, 2018

Did some initial research (lots of Apollo experience, none of Relay) and graphql-tag/loader should work for both Relay and Apollo. I could do some testing and submit a PR for .graphql loader if it works 👍

@iansu
Copy link
Contributor

iansu commented Jan 22, 2018

That would be great. Thanks!

@petetnt
Copy link
Contributor

petetnt commented Jan 23, 2018

Initial PR pending for the loader at #3909 👍

@guledali
Copy link

guledali commented Jun 26, 2018

@gaearon A minimal graphql client is the best option something like this

https://github.com/kadirahq/lokka
https://github.com/prismagraphql/graphql-request

This how gatsby does it

gatsby

@iansu
Copy link
Contributor

iansu commented Jun 27, 2018

I think this issue can be closed now. We have support for loading .graphql files in the next branch. People can easily add Apollo Client or URQL or one of the other clients mentioned above. I don't think we want to pick a client to ship with CRA.

@iansu iansu closed this as completed Jun 27, 2018
@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants