Closed longfellowone closed 4 years ago
If anyone is looking for a temporary fix
Create the file scrips/typescript-vue-apollo-patch.js
const fs = require('fs')
const path = require('path')
const loadGeneratedPath = path.resolve(__dirname, '../src/generated/graphql.ts')
fs.writeFileSync(
loadGeneratedPath,
fs
.readFileSync(loadGeneratedPath, 'utf8')
.replace(/@vue\/composition-api/m, 'vue')
)
In your package .json modify your generate script to
"scripts": {
"generate": "graphql-codegen --config codegen.yml && node scripts/typescript-vue-apollo-patch.js",
}
https://graphql-code-generator.com/docs/plugins/typescript-vue-apollo
overwrite: true
schema: 'http://localhost:8080/'
documents: 'src/**/*.graphql'
generates:
src/generated/graphql.ts:
plugins:
- typescript
- typescript-operations
- typescript-vue-apollo
config:
withCompositionFunctions: true
vueApolloComposableImportFrom: vue
does this fix your issue?
edit: looks like the import you need is not configurable, i'll make a PR for it
Fixed in @graphql-codegen/typescript-vue-apollo@2.1.0
.
Describe the bug
Generated file should import from 'vue' not '@vue/composition-api' when using vue 3
To Reproduce
Install vue 3, run generate
codegen.yml
config file:Expected behavior No error
Environment:
"@graphql-codegen/cli": "1.17.8"
"@graphql-codegen/typescript": "1.17.9"
"@graphql-codegen/typescript-operations": "1.17.8"
"@graphql-codegen/typescript-vue-apollo": "^2.0.0"