detrohutt / react-app-rewire-inline-import-graphql-ast

Add the inline-import-graphql-ast Babel plugin to your create-react-app app via react-app-rewired
MIT License
17 stars 2 forks source link

migrate to customize-cra #10

Closed stushurik closed 5 years ago

stushurik commented 5 years ago

When I use this with newer version of react-app-rewired (^2.x.x) I have got an error:

The "injectBabelPlugin" helper has been deprecated as of v2.0. You can use customize-cra plugins in replacement - https://github.com/arackaf/customize-cra#available-plugins
error Command failed with exit code 1.

This PR migrates to customize-cra helpers

stushurik commented 5 years ago

@detrohutt @Slessi what do you think about this?

Slessi commented 5 years ago

@stushurik Personally since CRA v2 I've been using https://github.com/evenchange4/graphql.macro

stushurik commented 5 years ago

@Slessi thanks for a hint!

@stushurik Personally since CRA v2 I've been using https://github.com/evenchange4/graphql.macro

graphql.macro looks cool, but in our project we prefer to keep gql in separate files. we have backend-for-fronted with apollo-server, with separate *.gql files and we want to stick to the same approach (separate gql from js) on both ends. So react-app-rewire-inline-import-graphql-ast is the least painful way to achieve that without ejecting

Slessi commented 5 years ago

@stushurik I am using that tool and still keeping my gql in separate files, but my point was I have no opinion on your change as I don't use this project anymore

stushurik commented 5 years ago

@Slessi Do you keep gql in *.js and export something like const query = gql.macro... ?

Slessi commented 5 years ago

https://github.com/evenchange4/graphql.macro#loader - read the docs, there is even an example repo

stushurik commented 5 years ago

@Slessi Oh, my fault miss that, it looks really good, with that I think that loader is much better approach. Thanks!

detrohutt commented 5 years ago

@detrohutt @Slessi what do you think about this?

Hey @stushurik, thanks for taking the time to make this PR! Everything looks good except that I think the "Usage" section of the docs will need to be updated maybe? Would you mind seeing if that's the case and updating it if necessary? Since I've started working for Delta my side project has been on hold so I haven't been using this package for a long time. It sounds like you're going to graphql.macro, so I understand if you don't want to spend the time looking into this. Thanks again for the PR!

stushurik commented 5 years ago

@detrohutt usage haven't changed at all. Public interface of react-app-rewire-inline-import-graphql-ast stay the same. I tested in my project and it works like a charm. So usage sections remains the same.

I am going to use graphql.macro because it allows me to not patch react scripts at all.

Nevertheless, some docs, like https://www.apollographql.com/docs/react/recipes/babel.html leads cra v2 users in the end to this package which does not work with latest version of react-app-rewired.

This package is stil useful so I think this PR can me merged.

detrohutt commented 5 years ago

@stushurik Awesome! Thanks for verifying. :) I'll go ahead and merge and publish a new version. On a side note, it looks like graphql.macro is missing some of the more advanced features such as multiple operations per .gql file.