-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Idea: Babel plugin should take a schema path from .babelrc
?
#819
Comments
.babelrc
?
@ianstormtaylor Until then you can use the babel-relay-plugin-loader in your |
I totally agree with @ianstormtaylor's suggestion and think it would be a big win in terms of minimising first steps when getting started with Relay. I just had a long conversation with the guys from Babel and learned that it's not really possible (or at least recommended) to wrap a babel plugin. The functionality should rather be included in the plugin itself. I really like the syntax Ian has proposed and did some research: It is possible to access the provided options ( @facebook-team: Is this something you would consider to implement? |
We're happy to support this. Note that this proposal avoids the main complication of previous suggestions to simplify the plugin such as this one, because it passes the schema in JSON form (loading a JS schema directly won't work bc of conflicting GraphQL versions and that cause Want to submit a PR for this? |
Unfortunately I don't have to time right now to properly dive into Babel in order to implement it. But I'm glad that this is something you guys are happy with as well :-) |
Update: We've built babel-plugin-react-relay supporting different source types such as JSON files, JS schema definitions and even URL schema endpoints. This is meant to provide a more convenient and powerful solution without the need for scripts like @ianstormtaylor would love to hear your thoughts on the API 👍 |
It would be great if Babel had some initialization stage, so that you could configure your plugins asynchronously. |
I will show when setting babelRelayPlugin in .babelrc |
Relay Modern is now out with a new plug-in and compiler architecture, so closing this because it is couched in terms of the old plug-in which is unlikely to be worked on further in the future. Please file any new issues against Relay Modern as separate issues. Thanks for the discussion! |
One of the biggest blockers to me diving into Relay (and even getting a working example once I had started) was installing the babel plugin and getting the schema bit of it hooked up. It was really complicated, confusing, and a big blocker to actually experimenting with Relay itself.
I think it would be a lot easier if the babel plugin would allow being passed a path to the file containing the schema, instead of the schema itself (or both for convenience). This would allow it to be fully configured from the
.babelrc
file instead of needing to create a separatebabel-plugin-relay.js
file somewhere in the directory. Like so:Which would be way simpler. I think this would require it being renamed to
babel-plugin-relay
instead ofbabel-relay-plugin
. Or you could usebabel-plugin-react-relay
if you wanted as well. (Actually looks like the rename is already ready here #732 .)The text was updated successfully, but these errors were encountered: