Webpack graphql-tag error: 無法解析 './*.graqhql'



我正尝试使用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

我已经安装了graphqlgraphql-tag

signin.graphql应该很好:

mutation Mutation($id: String!, $password: String!) {
signin(id: $id, password: $password) {
token,
user {
id
}
}
}

对不起,这是的拼写错误

import signin from "./signin.graqhql";
^*p

很容易错过这个。

最新更新