Closed stushurik closed 5 years ago
@detrohutt @Slessi what do you think about this?
@stushurik Personally since CRA v2 I've been using https://github.com/evenchange4/graphql.macro
@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
@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
@Slessi
Do you keep gql in *.js and export something like const query = gql.macro...
?
https://github.com/evenchange4/graphql.macro#loader - read the docs, there is even an example repo
@Slessi Oh, my fault miss that, it looks really good, with that I think that loader is much better approach. Thanks!
@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!
@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.
@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.
When I use this with newer version of react-app-rewired (^2.x.x) I have got an error:
This PR migrates to customize-cra helpers