I created a .gql
file for my query and I'm importing it like this:
const query = require("@/hello.gql");
However, if I log the query
variable to the console, it shows an object, not a string. What can I do so that my imported query is just a string?
Because, you are only importing the query, not using it.
You can use apollo to use that query like this
const yourQuery= require("@/hello.gql");
data(){
return {
queryResponse: []
}
}
apollo: {
queryResponse: {
prefetch: true,
query: yourQuery
}
}
Whit this, you are fetch the query and save the response in queryResponse