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

Respect type definitions for executeQuery #128

Closed
JarvisH opened this issue Jun 29, 2021 · 2 comments
Closed

Respect type definitions for executeQuery #128

JarvisH opened this issue Jun 29, 2021 · 2 comments

Comments

@JarvisH
Copy link

JarvisH commented Jun 29, 2021

In the documentation https://villus.logaretm.com/guide/typescript-codgen/#using-generated-queries it shows the following code example:

const { data } = useQuery<PostsQuery, PostsQueryVariables>({
  query: Posts
  variables: {
    // variables are now typed as PostsQueryVariables
  },
});

data.value; // is now typed as PostsQuery type!

This does not appear to work when using executeQuery instead of useQuery. In the villus.d.ts file the following signature is found:

executeQuery<TData = any, TVars = QueryVariables>(operation: OperationWithCachePolicy<TData, TVars>, queryContext?: QueryExecutionContext): Promise<OperationResult>;

Is it as simple as adding TData to OperationResult?

@logaretm
Copy link
Owner

Thanks for reporting this, yes you are right it is as you suggested. You should find the updated types in rc.18

@JarvisH
Copy link
Author

JarvisH commented Jun 30, 2021

Thank you for the quick fix, you rock!

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