apollo: Can`t load .gql files
Version
Reproduction link
https://github.com/nuxt-community/apollo-module
Steps to reproduce
From official example.
<template>
<div>
....
</div>
</template>
<script>
import allCars from '~/apollo/queries/allCars'
export default {
}
</script>
And the query apollo/queries/allCars.gql
{
allCars {
id
make
model
year
}
}
Am i missing something?
What is expected ?
Should import the .gql file
What is actually happening?
This dependency was not found:
- @/apollo/queries/allCars in ./node_modules/babel-loader/lib?{“babelrc”:false,“cacheDirectory”:true,“presets”:[[“/var/www/node_modules/babel-preset-vue-app/dist/index.common.js”,{“targets”:{“ie”:9,“uglify”:true}}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./pages/cars.vue
To install it, you can run: npm install --save @/apollo/queries/allCars
Additional comments?
Also including extension .gql does not work.
import allCars from '~/apollo/queries/allCars.gql'
My nuxt.config.js
modules: [
'@nuxtjs/apollo',
],
apollo: {
includeNodeModules: true,
clientConfigs: {
default: {
httpEndpoint: 'http://my-api.com/graphql',
}
}
}
<div align="right">This bug report is available on Nuxt community (#c106)</div>About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (8 by maintainers)
@robsontenorio not everybody is using *.gql files so its not part of the module. I will add note thanks for bringing this up
Ok, the problem is: an additional step is required.
The apollo module was not supposed to manage this dependency?
Hello, Thanks for your help. I was using nuxt.config.js this way https://github.com/nuxt/nuxt.js/blob/dev/examples/vue-apollo/nuxt.config.js For some reason, it does not work. I replaced with your version of nuxt.config and it is working now. Thanks
@dohomi no lucky with relative folder, and
.gqlextension on import statement as suggested.Step by step
Create a nuxt app with yarn.
Options:
On
my-appfolder, update nuxt version to 1.4.1 and add apollo moduleOn
nuxt.config.jsCreate
apollo/queries/allCars.gqlCreate
pages/cars.vueNote
With
create-nuxt-appthenuxt.config.jshas this default entry. Maybe something here is causing problem on gql loader?