我正尝试使用graphql-tag
,使用webpack
从.graphql
文件导入graphql
查询,如下所述。
因此,我的webpack.config
看起来是这样的:
{
// ...
module: {
rules: [{
test: /.(graphql|gql)$/,
exclude: /node_modules/,
loader: "graphql-tag/loader",
}],
},
entry: "./index.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "../dist"),
},
mode: "development",
}
执行
import signin from "./signin.graqhql";
index.js
内部产生webpack
错误
ERROR in ./index.js 1:0-35
Module not found: Error: Can't resolve './signin.graqhql' in 'D:DevOpsFooappsrc'
resolve './signin.graqhql' in 'D:DevOpsFooappsrc'
using description file: D:DevOpsFooapppackage.json (relative path: ./src)
Field 'browser' doesn't contain a valid alias configuration
using description file: D:DevOpsFooapppackage.json (relative path: ./src/signin.graqhql)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:DevOpsFooappsrcsignin.graqhql doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
D:DevOpsFooappsrcsignin.graqhql.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
D:DevOpsFooappsrcsignin.graqhql.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
D:DevOpsFooappsrcsignin.graqhql.wasm doesn't exist
as directory
D:DevOpsFooappsrcsignin.graqhql doesn't exist
我已经安装了graphql
和graphql-tag
。
signin.graphql
应该很好:
mutation Mutation($id: String!, $password: String!) {
signin(id: $id, password: $password) {
token,
user {
id
}
}
}
对不起,这是的拼写错误
import signin from "./signin.graqhql";
^*p
很容易错过这个。