Skip to content

simplify GraphQL files loading#12120

Open
mrduguo wants to merge 1 commit into
react:mainfrom
mrduguo:main
Open

simplify GraphQL files loading#12120
mrduguo wants to merge 1 commit into
react:mainfrom
mrduguo:main

Conversation

@mrduguo
Copy link
Copy Markdown

@mrduguo mrduguo commented Mar 3, 2022

use simpler graphql-tag/loader other than graphql.macro

Document updated as well. You may see how it was looks before and after:
Screenshot_2022-03-03_at_22_53_51

The implementation has been published as graphql-tag-react-scripts@5.0.2

Manual test for none GraphQL project

npx create-react-app none-gql-project --scripts-version graphql-tag-react-scripts@5.0.2
cd none-gql-project
npm run build
# expected build success without error

Manual test for Apollo based GraphQL project

npx create-react-app apollo-gql-project --scripts-version graphql-tag-react-scripts@5.0.2
cd apollo-gql-project
npm install --save @apollo/client
cat <<EOT > src/index.js
import query from './foo.graphql';
console.log(query)
EOT

cat <<EOT > src/foo.graphql
query {
  hello {
    world
  }
}
EOT

npm run build
grep hello build/static/js/main.*.js

# expect contain the hello keyword

@mrduguo mrduguo marked this pull request as draft March 4, 2022 20:18
@mrduguo mrduguo marked this pull request as ready for review March 4, 2022 21:08
@mrduguo
Copy link
Copy Markdown
Author

mrduguo commented Mar 4, 2022

Made some improvement to make sure it works for project without graphql-tag dependency. Manual tests added in first comment.

Please let me known if any other improvement required.

@mrmckeb wish you safe and well. #ukrainestrong 🇺🇦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants