Skip to content

Commit c9f34df

Browse files
author
craineum
authored
Merge pull request #14 from CodingZeal/graphql
Add GraphQL loader
2 parents da5d172 + aae3988 commit c9f34df

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

packages/react-scripts/config/webpack.config.dev.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,12 @@ module.exports = {
195195
// "file" loader makes sure those assets get served by WebpackDevServer.
196196
// When you `import` an asset, you get its (virtual) filename.
197197
// In production, they would get copied to the `build` folder.
198-
// ZEAL: Add .scss because we add the sass-loader below.
198+
// ZEAL: Add .scss and .graphql because we add the loaders below
199199
{
200200
exclude: [
201201
/\.html$/,
202202
/\.(js|jsx)$/,
203+
/\.(graphql|gql)$/,
203204
/\.css$/,
204205
/\.scss$/,
205206
/\.json$/,
@@ -307,6 +308,12 @@ module.exports = {
307308
require.resolve('sass-loader'),
308309
],
309310
},
311+
// ZEAL: Adds support for parsing GraphQL files
312+
{
313+
test: /\.(graphql|gql)$/,
314+
exclude: /node_modules/,
315+
loader: 'graphql-tag/loader',
316+
},
310317
// ** STOP ** Are you adding a new loader?
311318
// Remember to add the new extension(s) to the "file" loader exclusion list.
312319
],

packages/react-scripts/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@
4343
"extract-text-webpack-plugin": "2.1.0",
4444
"file-loader": "0.11.1",
4545
"fs-extra": "3.0.1",
46+
"graphql-tag": "^2.4.2",
4647
"html-webpack-plugin": "2.28.0",
4748
"identity-obj-proxy": "^3.0.0",
4849
"jest": "20.0.3",
50+
"jest-transform-graphql": "^2.1.0",
4951
"json-loader": "0.5.4",
5052
"node-sass": "3.13.1",
5153
"object-assign": "4.1.1",

packages/react-scripts/scripts/utils/createJestConfig.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ module.exports = (resolve, rootDir, isEjecting) => {
4141
: resolve('config/jest/babelTransform.js'),
4242
'^.+\\.css$': resolve('config/jest/cssTransform.js'),
4343
'^(?!.*\\.(js|jsx|css|json)$)': resolve('config/jest/fileTransform.js'),
44+
// ZEAL: Adds support for parsing GraphQL files
45+
'^.+\\.(gql|graphql)$': require.resolve('jest-transform-graphql'),
4446
},
4547
transformIgnorePatterns: [
4648
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$',

packages/react-scripts/yarn.lock

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,10 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
27322732
version "1.0.1"
27332733
resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"
27342734

2735+
graphql-tag@^2.4.2:
2736+
version "2.4.2"
2737+
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.4.2.tgz#6a63297d8522d03a2b72d26f1b239aab343840cd"
2738+
27352739
growly@^1.3.0:
27362740
version "1.3.0"
27372741
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
@@ -2956,7 +2960,7 @@ icss-replace-symbols@^1.0.2:
29562960
version "1.0.2"
29572961
resolved "https://registry.yarnpkg.com/icss-replace-symbols/-/icss-replace-symbols-1.0.2.tgz#cb0b6054eb3af6edc9ab1d62d01933e2d4c8bfa5"
29582962

2959-
2963+
identity-obj-proxy@^3.0.0:
29602964
version "3.0.0"
29612965
resolved "https://registry.yarnpkg.com/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz#94d2bda96084453ef36fbc5aaec37e0f79f1fc14"
29622966
dependencies:
@@ -3547,6 +3551,10 @@ jest-snapshot@^20.0.3:
35473551
natural-compare "^1.4.0"
35483552
pretty-format "^20.0.3"
35493553

3554+
jest-transform-graphql@^2.1.0:
3555+
version "2.1.0"
3556+
resolved "https://registry.yarnpkg.com/jest-transform-graphql/-/jest-transform-graphql-2.1.0.tgz#903cb66bb27bc2772fd3e5dd4f7e9b57230f5829"
3557+
35503558
jest-util@^20.0.3:
35513559
version "20.0.3"
35523560
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-20.0.3.tgz#0c07f7d80d82f4e5a67c6f8b9c3fe7f65cfd32ad"

0 commit comments

Comments
 (0)