I'm using Nuxt.js(vuex) + Apollo.
Now, i'm working hard to get typescript into this project, especially around graphql. I read this article and generate type file but it does not work. I cannot import query at .ts
file in store directory.
generated type file. (~/graphql/types.d.ts
)
~~ declare module '*/activate.gql' { import { DocumentNode } from 'graphql'; <- another problem: ts says "error TS2307: Cannot find module 'graphql'" const defaultDocument: DocumentNode; export default defaultDocument; } ~~
this is generated by codegen.yml
schema: http://localhost:3000/graphql generates: ./graphql/types.d.ts: documents: ./graphql/**/*.gql plugins: - typescript - typescript-graphql-files-modules
I cannot import activate
query at store. (~/store/user.ts
)
import activate from '~/graphql/mutations/activate.gql'; <- "error TS2307: Cannot find module '~/graphql/mutations/auth/activate.gql'"
According to the above document, this will work...
Directory structure is here.
- graphql |- queries |- mutations |- activate.gql |- types.d.ts - store |- user.ts - codegen.yml
I would greatly appreciate it if you could answer...
https://stackoverflow.com/questions/66947199/cannot-import-graphql-query-at-typescript-file April 05, 2021 at 09:08AM
没有评论:
发表评论