typescript-vue-urql
generate an error type in hooks
#3349
-
This is my codegen to get the vue hook ready to use in my code: const config: CodegenConfig = {
schema: 'https://countries.trevorblades.com/',
documents: ['graphql/resolvers/**/*.ts'],
ignoreNoDocuments: true, // for better experience with the watcher
generates: {
'graphql/generated/graphql.ts': {
config: {
withComposition: true,
},
plugins: [
'typescript',
'typescript-operations',
//'typescript-urql',
'typescript-vue-urql',
],
},
'graphql/generated/graphql.schema.ts': {
plugins: [
'urql-introspection',
],
},
},
}; It generated the graphql functions and types. But it generate a hooks with a type issue: Hook created: export function useAllCountriesQuery(options: Omit<Urql.UseQueryArgs<never, AllCountriesQueryVariables>, 'query'> = {}) {
return Urql.useQuery<AllCountriesQuery>({ query: AllCountriesDocument, ...options });
}; Issue:
I don't know how to solve it or if it's a codegen issue. Help me please. I need to use I created an repository example here you can use to replicate this issue. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The types in all urql bindings aren't that simple anymore, so old GCG generators that "wrap" functions like I'd recommend however not to try to solve this and not to generate wrapper hooks at all. Instead, it's recommended to switch to a GCG output that generates This is further explained here: https://formidable.com/open-source/urql/docs/basics/typescript-integration/ |
Beta Was this translation helpful? Give feedback.
That's not our documentation, so I couldn't tell you. We also never recommended to generate wrapper hooks/functions, ever 😅 It's generally something I never recommended and we didn't even document
TypedDocumentNode
in our docs until recently (although it's been supported for a long time).While we're working on our own tooling, which isn't ready yet, we can really only recommend any
TypedDocumentNode
tooling for now, and that tooling will also be based on outputtingTypedDocumentNode
-based typings.If you have questions for the GCG team, then I'd recommend you to go to them and ask whether this package is even still supported. Just mind you, a lot of their packages have been deprecated, a…