-
-
Notifications
You must be signed in to change notification settings - Fork 522
Open
Description
Hi,
I’m experiencing an issue with automatic type inference for GraphQL queries when using composables. I previously had it working, but it no longer works, and I can’t figure out why.
🎯 Context
- Framework: Vue 3
- Apollo Client version: 3.12.9
- @vue/apollo-composable version: 4.2.1
- Bundler: Vite
- Package manager: pnpm
🛠️ GraphQL Codegen configuration
I use graphql-codegen with the following config:
...
generates:
./src/models/generated/graphql/:
preset: 'client'
config:
useTypeImports: true
presetConfig:
fragmentMasking: false
./src/models/generated/graphql/schema.graphql:
plugins:
- 'schema-ast'
config:
includeDirectives: true
commentDescriptions: true
...
🛠️ TypeScript configuration for .gql files
declare module '*.gql' {
import type { DocumentNode } from 'graphql';
const value: DocumentNode;
export = value;
}
🐛 Issue description
Type inference does not work as expected when using useLazyQuery with a DocumentNode.
Example code:
import BASKET_SUMMARY_QUERY from '@/graphql/queries/basketSummary.gql';
const { load, error, result } = useLazyQuery(BASKET_SUMMARY_QUERY, queryVariables, {
errorPolicy: 'all',
fetchPolicy: 'no-cache',
keepPreviousResult: true,
enabled,
});
❓ Questions
- Is type inference via DocumentNode still expected to work with @vue/apollo-composable?
- Is there any specific configuration needed to ensure TypeScript correctly infers query types?
- Have there been any recent changes in @vue/apollo-composable or Apollo Client that might explain this behavior?
Thanks in advance for your help! 🙏
Metadata
Metadata
Assignees
Labels
No labels