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

Request for a working example with React and TypeScript. #382

Open
yaldram opened this issue Feb 2, 2019 · 0 comments
Open

Request for a working example with React and TypeScript. #382

yaldram opened this issue Feb 2, 2019 · 0 comments

Comments

@yaldram
Copy link

yaldram commented Feb 2, 2019

Hello Sir thank you for this awesome libraries it adds a lot to the basic apollo-link-state library. I did your book example with React (jsx) it worked and I loved the way this library worked, but when I started working in typescript and React (tsx) I am getting all type Errors.

1. The connect HOC  gives type Errors ->
interface IStaffFilterProps  {
    updateFirst: (first: string) => void;
}

const mapDispatchToProps = (dispatch: Dispatch) => ({
  updateFirst: (first: string) => dispatch(new UpdateFirst(first)),
});

class StaffScreenFilters extends Component<IStaffFilterProps, {}> { }
 connect(mapDispatchToProps)(StaffScreenFilters);
  1. In your example you have Actions as Mutations Properties (type and mutation) as static class Properties t gives errors here -> dispatch(new UpdateFirst(first)) i . So I had to remove static : -
export class UpdateFirst {
    
    type = '[First] Update';
    
    mutation = gql `
        mutation updateFirst($first: String!) {
            updateFirst($first: String!)
        }
    `;

    variables: { first: string };

    constructor(first: string) {
        this.variables = {
            first
        };
    }
  1. The mutation resolver below is asking for the type of context :-
export class StaffState {
    updateFirst({ title }, context) {
        context.patchQuery()
    }
}

Please Sir a simple working example in typescript would help me a lot Thank you for your time

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

1 participant