我尝试将Este boilerplate用于带有中继现代(^ 4)和打字稿的react-native应用程序。但是我通过运行应用程序得到了一个错误
graphql:运行时发生意外调用。 Babel变换 未设置,或者无法识别此呼叫站点。确保它 被逐字用作graphql
我应该如何配置babel?
我尝试使用packages / native / babel.config.js安装babel-plugin-relay
module.exports = api => {
api.cache(false);
const plugins = [
['relay', {artifactDirectory: '../relay/generated'}]
];
const presets = ['module:metro-react-native-babel-preset'];
return {plugins, presets};
};
但它似乎被忽略了
我的程序包/native/metro.config.js
const path = require('path');
module.exports = {
projectRoot: path.resolve(__dirname, '../../'),
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
packeges / native / package.json
{
"name": "@app/native",
"version": "1.0.0",
"private": true,
"scripts": {
"dev:ios": "react-native run-ios",
"dev:android": "react-native run-android",
"start": "node ../../node_modules/react-native/local-cli/cli.js start --projectRoot ../../",
"test": "jest"
},
"dependencies": {
"@app/components": "1.0.0",
"react": "^16.8.6",
"react-native": "^0.59.5",
"react-native-gesture-handler": "^1.3.0",
"react-navigation": "^3.11.0"
},
"devDependencies": {
"@babel/core": "^7.4.3",
"@babel/runtime": "^7.4.3",
"@types/jest": "^24.0.11",
"@types/react": "^16.8.13",
"@types/react-native": "^0.57.43",
"babel-jest": "^24.7.1",
"babel-plugin-relay": "^4.0.0",
"graphql": "^14.3.1",
"jest": "^24.7.1",
"metro-react-native-babel-preset": "^0.54.0"
},
"jest": {
"preset": "react-native"
}
}
中继编译器命令(在packages / relay / package.json中):
relay-compiler --src '../' --schema '../api/schema.graphql' --language typescript --artifactDirectory 'generated'