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

Commit

Permalink
Add type for mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
MargaretKrutikova committed Sep 14, 2019
1 parent 25895e0 commit d4cc1a5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/Mutation.re
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ type error = {
"graphlErrors": graphqlErrors,
};

type refetchQueries =
ReasonApolloTypes.executionResult => array(ApolloClient.queryObj);

/* Result that is return by the hook */
type result('a) =
| Data('a)
Expand Down Expand Up @@ -45,8 +48,7 @@ module Make = (Config: Config) => {
[@bs.optional]
client: ApolloClient.generatedApolloClient,
[@bs.optional]
refetchQueries:
ReasonApolloTypes.executionResult => array(ApolloClient.queryObj),
refetchQueries,
[@bs.optional]
awaitRefetchQueries: bool,
[@bs.optional]
Expand All @@ -62,6 +64,15 @@ module Make = (Config: Config) => {
};

type jsMutate = (. options) => Js.Promise.t(jsResult);
type mutate =
(
~variables: Js.Json.t=?,
~client: ApolloClient.generatedApolloClient=?,
~refetchQueries: refetchQueries=?,
~awaitRefetchQueries: bool=?,
unit
) =>
Js.Promise.t(controledVariantResult(Config.t));

[@bs.module "@apollo/react-hooks"]
external useMutation:
Expand Down Expand Up @@ -90,7 +101,7 @@ module Make = (Config: Config) => {
),
);

let mutate =
let mutate: mutate =
React.useMemo1(
(
(),
Expand Down

0 comments on commit d4cc1a5

Please sign in to comment.