Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

types for lazy hook are incorrect (only two available) #3787

Closed
maapteh opened this issue Jan 8, 2020 · 0 comments
Closed

types for lazy hook are incorrect (only two available) #3787

maapteh opened this issue Jan 8, 2020 · 0 comments

Comments

@maapteh
Copy link
Contributor

maapteh commented Jan 8, 2020

I'm using 3.1.2 and see the generated types for a lazy hook are missing a lot of the default options.

The query (non-lazy) one extends on the base which has all options as documented and correctly.

export interface QueryOptions<TData = any, TVariables = OperationVariables> extends QueryFunctionOptions<TData, TVariables> {
    children?: (result: QueryResult<TData, TVariables>) => ReactNode;
    query: DocumentNode;
}

While the lazy options are only referring to:

export interface QueryLazyOptions<TVariables> {
    variables?: TVariables;
    context?: Context;
}

So at the moment, i'm unable to set for example fetchPolicy as documented on https://www.apollographql.com/docs/react/api/react-hooks/#uselazyquery when using your generated types. When using the useLazyQuery from the library:

export declare function useLazyQuery<TData = any, TVariables = OperationVariables>(
    query: DocumentNode,
    options?: LazyQueryHookOptions<TData, TVariables>
): [(options?: import("./types").QueryLazyOptions<TVariables> | undefined) => void, import("@apollo/react-common").QueryResult<TData, TVariables>];

This is a bug :) and created a PR for it

environment:

  System:
    OS: macOS Mojave 10.14.1
  Binaries:
    Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
    Yarn: 1.19.1 - ~/.nvm/versions/node/v10.16.3/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm
  Browsers:
    Chrome: 79.0.3945.117
    Firefox: 69.0.3
    Safari: 12.0.1
  npmPackages:
    @apollo/react-hooks: 3.1.2 => 3.1.2 
    @apollo/react-ssr: 3.1.2 => 3.1.2 
    @apollo/react-testing: 3.1.2 => 3.1.2 
    apollo-cache-inmemory: 1.6.3 => 1.6.3 
    apollo-client: 2.6.4 => 2.6.4 
    apollo-link: 1.2.13 => 1.2.13 
    apollo-link-batch-http: 1.2.13 => 1.2.13 
    apollo-link-error: 1.1.12 => 1.1.12 
    apollo-link-http: 1.5.16 => 1.5.16 
    apollo-link-logger: 1.2.3 => 1.2.3 
    apollo-link-schema: 1.2.4 => 1.2.4 
    apollo-link-state: 0.4.2 => 0.4.2 
@maapteh maapteh changed the title types for lazy hook incorrect types for lazy hook are incorrect (only two available) Jan 8, 2020
@maapteh maapteh closed this as completed Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant