Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use TypedDocumentNode instead of hook generation #447

Open
cybersiddhu opened this issue Dec 16, 2021 · 2 comments
Open

use TypedDocumentNode instead of hook generation #447

cybersiddhu opened this issue Dec 16, 2021 · 2 comments
Assignees

Comments

@cybersiddhu
Copy link
Member

const { loading, error, data } = usePublicationQuery({

Here is a approach that makes it little easier to use typescript with graphql query

const {......} = useQuery(PublicationDocument,{})

https://charlypoly.com/publications/typescript-with-graphql-done-right
https://github.com/dotansimha/graphql-typed-document-node

It is already defined in dicty-graphql-schema package

@ayaanqui
Copy link
Contributor

@cybersiddhu One issue that I found with that is the { data } object returned by useQuery is of type any. So either we stick with that or use type casting to convert it to Publication

@ayaanqui
Copy link
Contributor

const id = ""
const { loading, error, data } = useQuery(PublicationDocument, {variables: id})

Here, data is returned as type any

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants