Skip to content
This repository was archived by the owner on Jul 6, 2020. It is now read-only.
This repository was archived by the owner on Jul 6, 2020. It is now read-only.

Add generic types for updates #75

@lukasluecke

Description

@lukasluecke

I have the following code (in updates.Mutation) to update a list count after creating an item:

createItem: (result, args, cache, info) => {
    cache.updateQuery({query: ListDocument, variables: {parentId: args.input.parent}}, data => {
        data.parent.items.totalCount = data.parent.items.totalCount + 1;
        return data;
    })
}

There's currently no validation / hints on variables or data, which should be possible by passing the respective types as generics to updateQuery (similar to how useQuery/useMutation hooks work).

I also get a typescript error on data.parent.items:

Property items does not exist on type DataField


It would also be great to have the possibility to type the whole function createItem, so we could have validation / hints on args and result as well.

Right now I get another typescript error on args.input.parent:

Property parent does not exist on type string | number | boolean | Variables | ScalarObject | Scalar[] | Variables[]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions