Open
Description
Essentially when using useQuery
or useMutation
, any query/mutation type does not get infered for the data object.
import { graphql } from 'gql.tada';
import { useQuery } from 'villus';
const getBooksQuery = graphql(`
query GetBooks {
books {
id
title
}
}
`);
const { data, error } = useQuery({
query: getBooksQuery
});
data // globalThis.Ref<any>
This can be fixed if we provide the types directly
import { graphql } from 'gql.tada';
import { useQuery } from 'villus';
const getBooksQuery = graphql(`
query GetBooks {
books {
id
title
}
}
`);
const { data, error } = useQuery<typeof getBooksQuery>({
query: getBooksQuery
});
However it would be great if these are automatically set, similiar to
https://villus.logaretm.com/guide/typescript-codgen/#using-typed-document.
Not sure if this would be possible!
Metadata
Metadata
Assignees
Labels
No labels