question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing/incomplete mutate function variables types

See original GitHub issue

Hi, I started using graphql-let yesterday as a replacement for GraphQL Code Generator. Today I noticed a weird issue with types not being as strong as I’d like.

Maybe I remember wrong, but while using GraphQL Code Generator, I think I had variables of the mutate function typed and VSCode provided autocomplete when writing them. Here is an example of what I mean:

import { useChangeTickerMutation } from './tickersMutations.graphql'

const Example: FC = () => {
  const [changeTicker] = useChangeTickerMutation({ variables: { } })
  //                                                           ^ autocomplete/typecheck works here

  const sendUpdate = () => changeTicker({ variables: { } })
  //                                                  ^ autocomplete/typecheck doesn't work here (`variables` are `any`)
  ...
}

I tracked this to the tickersMutations.graphql.d.ts file:

export declare function useChangeTickerMutation(baseOptions?: Apollo.MutationHookOptions<ChangeTickerMutation, ChangeTickerMutationVariables>): Apollo.MutationTuple<ChangeTickerMutation, any>;

I believe there should be Apollo.MutationTuple<ChangeTickerMutation, ChangeTickerMutationVariables> in the end.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
piglovesyoucommented, May 28, 2021

@rtrembecky Great, thanks for taking your time. I’ll publish v0.18.1 soon.

2reactions
rtrembeckycommented, May 27, 2021

I took a bit of a dive into your codebase, it seems there are no tests/examples for mutations. Luckily, I think I found the same problems for queries. E.g. in https://github.com/piglovesyou/graphql-let/blob/main/src/__snapshots__/gen.test.ts.snap#L58-L59:

export declare function useViewerQuery(baseOptions?: Apollo.QueryHookOptions<ViewerQuery, ViewerQueryVariables>): Apollo.QueryResult<ViewerQuery, any>;
export declare function useViewerLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ViewerQuery, ViewerQueryVariables>): Apollo.QueryTuple<ViewerQuery, any>;

Both of these should have ViewerQueryVariables instead of any as a second generic type argument to Apollo.QueryResult/QueryTuple respectively.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data Cleaning with R and the Tidyverse: Detecting Missing ...
This is just a quick look to see the variable names and expected variable types. Looking at the dimensions of the data is...
Read more >
Refetching queries in Apollo Client - Apollo GraphQL Docs
To selectively refetch queries outside of a mutation, you instead use the refetchQueries method of ApolloClient , which is documented here. client.
Read more >
Complete a data frame with missing combinations of data - tidyr
To find all unique combinations of x , y and z , including those not present in the data, supply each variable as...
Read more >
applying dplyr functions simultaneously across multiple columns
This shows that there are missing values in every column except for the first two ( species and island ).
Read more >
35 Column-wise operations in dplyr | R for Epidemiology
For example, we passed the mean function to the .fns argument above. In the data frame above, none of the columns had any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found