Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Type-safe useQuery #129

Open
tsnobip opened this issue May 29, 2020 · 1 comment
Open

Type-safe useQuery #129

tsnobip opened this issue May 29, 2020 · 1 comment

Comments

@tsnobip
Copy link

tsnobip commented May 29, 2020

Right now, ~variables expects any type:

let useQuery:
  (
    ~client: ApolloClient.t=?,
    ~variables: 'raw_t_variables=?,
    ~notifyOnNetworkStatusChange: bool=?,
    ~fetchPolicy: ApolloHooksTypes.fetchPolicy=?,
    ~errorPolicy: ApolloHooksTypes.errorPolicy=?,
    ~skip: bool=?,
    ~pollInterval: int=?,
    ~context: Context.t=?,
    graphqlDefinition('t, 'raw_t)
  ) =>
  (variant('t), queryResult('t, 'raw_t, 'raw_t_variables))

So if you partially apply makeVariables by forgetting a non-optional argument for example, this won't be detected by the type-checker.

Any idea how to solve this?

@jeddeloh
Copy link
Member

jeddeloh commented Jun 7, 2020

This should be resolved in both #117 and #122 branches. The variables arg is required and there are some convenience functions and Extension modules for making the ergonomics better.

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

No branches or pull requests

2 participants