Skip to content

Commit

Permalink
Merge pull request #126 from Arnarkari93/feature-cache-extract
Browse files Browse the repository at this point in the history
feat: add apollo.extract method
  • Loading branch information
jeddeloh authored Sep 20, 2021
2 parents 7b9c063 + abb6476 commit 6e6cc46
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/@apollo/client/core/ApolloClient__Core_ApolloClient.res
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ module Js_ = {
@send
external clearStore: t => Js.Promise.t<array<Js.Json.t>> = "clearStore"


// extract(optimistic?: boolean): TCacheShape;
@send
external extract: (t, ~optimistic: bool=?, unit) => Js.Json.t = "extract"

// mutate<T = any, TVariables = OperationVariables>(options: MutationOptions<T, TVariables>): Promise<FetchResult<T>>;
@send
external mutate: (
Expand Down Expand Up @@ -392,6 +397,8 @@ module Js_ = {
type t = {
@as("rescript_clearStore")
clearStore: unit => Js.Promise.t<Belt.Result.t<array<Js.Json.t>, Js.Exn.t>>,
@as("rescript_extract")
extract: (~optimistic: bool=?, unit) => Js.Json.t,
@as("rescript_mutate")
mutate: 'data 'variables 'jsVariables. (
~mutation: module(Operation with
Expand Down Expand Up @@ -576,6 +583,8 @@ let make: (
->Js.Promise.then_(value => Js.Promise.resolve(Ok(value)), _)
->Js.Promise.catch(e => Js.Promise.resolve(Error(Utils.ensureError(Any(e)))), _)

let extract = (~optimistic=?, ()) => jsClient->Js_.extract(~optimistic=?optimistic, ())

let mutate = (
type data variables jsVariables,
~mutation as module(Operation: Operation with
Expand Down Expand Up @@ -888,6 +897,7 @@ let make: (
jsClient,
{
clearStore: clearStore,
extract: extract,
mutate: mutate,
onClearStore: onClearStore,
onResetStore: onResetStore,
Expand Down

0 comments on commit 6e6cc46

Please sign in to comment.