Skip to content

Make type generic for mutation for onError function #167

@LFSCamargo

Description

@LFSCamargo

The Problem

The return type for the server is different from the relay error type so i created the interface and a helper to handle errors and i got the error bellow i think a good solution would be to add the generic type to the useMutation hook

Behaviour

Screen Shot 2021-03-11 at 8 55 08 PM

How i thought to resolve this issue

export interface MutationConfig<TOperation extends MutationParameters, TError = Error> {
    configs?: DeclarativeMutationConfig[];
    cacheConfig?: CacheConfig;
    mutation: GraphQLTaggedNode;
    onError?: ((error: Error) => void) | null;
    onCompleted?:
        | ((response: TOperation['response'], errors: ReadonlyArray<PayloadError> | null | undefined) => void)
        | null;
    onUnsubscribe?: () => void | null | undefined;
    optimisticResponse?: TOperation['response'];
    optimisticUpdater?: SelectorStoreUpdater<TOperation['response']> | null;
    updater?: SelectorStoreUpdater<TOperation['response']> | null;
    uploadables?: UploadableMap | null;
    variables: TOperation['variables'];
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions