[英]Vetur error when using multiple queries in same .gql file
I am using Vue typeScript with GraphQL.我在 GraphQL 中使用 Vue typeScript。 Whenever I try to use a query using deconstructor I get an error from Vetur.
每当我尝试使用解构器使用查询时,我都会收到来自 Vetur 的错误消息。 I am able to use GetPostData query in the Vue Component and its working fine.
我能够在 Vue 组件中使用 GetPostData 查询并且它工作正常。
Trying to use this - https://github.com/apollographql/graphql-tag#support-for-multiple-operations尝试使用这个 - https://github.com/apollographql/graphql-tag#support-for-multiple-operations
Vue File Vue文件
import { GetPostData } from "../../util/queries/getPageData.gql";
getPageData.gql获取页面数据.gql
query GetPostData {
continents {
code
}
}
query GetCountries($code: String!) {
country(code: $code) {
code
}
}
Vue.config.js Vue.config.js
const antdTheme = require("./src/theme.js");
module.exports = {
publicPath: "/",
pwa: {
iconPaths: {
favicon32: "./favicon.png",
favicon16: "./favicon.png",
appleTouchIcon: "./favicon.png",
maskIcon: "./favicon.png",
msTileImage: "./favicon.png"
}
},
css: {
loaderOptions: {
less: {
modifyVars: antdTheme,
javascriptEnabled: true
}
}
},
chainWebpack: config => {
// GraphQL Loader
config.module
.rule("graphql")
.test(/\.(graphql|gql)$/)
.use("graphql-tag/loader")
.loader("graphql-tag/loader")
.end();
}
};
I think it states that's what you can do but I don't think you really can.我认为它表明这是你可以做的,但我不认为你真的可以。 It's better to put all your queries in a javascript file and import 'graphql-tag' to store queries instead of using a .gql file.
最好将所有查询放在一个 javascript 文件中并导入 'graphql-tag' 来存储查询,而不是使用 .gql 文件。
Just tested and Vetur didn't complain, could have been a bug that is already fixed.刚刚测试,Vetur 没有抱怨,可能是一个已经修复的错误。
According to graphql-tag package this case is supported ( docs ), so if Vetur complains must be an issue with the extension itself.根据 graphql-tag 包,这种情况得到支持( docs ),所以如果 Vetur 抱怨一定是扩展本身的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.