From 5ad1433eec5ae14a0aa1a73b8ca497be4594f3c3 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Thu, 3 Jun 2021 14:51:48 +0800 Subject: [PATCH 1/4] Add toReference to fieldPolicies This works, but you might have ideas how to implement this, don't know if this fits well in the architecture? --- ...lloClient__Cache_InMemory_Policies_FieldPolicy.res | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res b/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res index 9f7f455..602441b 100644 --- a/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res +++ b/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res @@ -20,7 +20,8 @@ module StorageType = { module FieldFunctionOptions = { type unimplemented - + type reference = {__typename: string, id: string} + module Js_ = { // export interface FieldFunctionOptions, TVars = Record> { // args: TArgs | null; @@ -55,7 +56,7 @@ module FieldFunctionOptions = { "canRead" @bs.send external readField: t => ReadFieldFunction.Js_.t = "readField" @bs.send - external toReference: t => ToReferenceFunction.t = "toReference" + external toReference: (t, reference) => unit = "toReference" } type t = { @@ -65,7 +66,7 @@ module FieldFunctionOptions = { field: Js.nullable, variables: option>, isReference: bool, - toReference: unimplemented, + toReference: reference => unit, storage: Js.nullable, cache: ApolloCache.t, readField: unimplemented, @@ -80,7 +81,9 @@ module FieldFunctionOptions = { field: js.field, variables: js.variables, isReference: js.isReference, - toReference: js.toReference, + toReference: (reference: reference) => { + js->Js_.toReference(reference) + }, storage: js.storage, cache: js.cache, readField: js.readField, From 584f72f998d25e49b67312b1a423959658a2ddb1 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Thu, 3 Jun 2021 15:06:23 +0800 Subject: [PATCH 2/4] Do not depend on record --- .../ApolloClient__Cache_InMemory_Policies_FieldPolicy.res | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res b/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res index 602441b..3a7c2f2 100644 --- a/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res +++ b/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res @@ -66,7 +66,7 @@ module FieldFunctionOptions = { field: Js.nullable, variables: option>, isReference: bool, - toReference: reference => unit, + toReference: (~typename: string, ~id: string) => unit, storage: Js.nullable, cache: ApolloCache.t, readField: unimplemented, @@ -81,8 +81,8 @@ module FieldFunctionOptions = { field: js.field, variables: js.variables, isReference: js.isReference, - toReference: (reference: reference) => { - js->Js_.toReference(reference) + toReference: (~id, ~typename) => { + js->Js_.toReference({id: id, __typename: typename}) }, storage: js.storage, cache: js.cache, From afbb0d3bfbde60a9a79893e72dd894c5daf41ab8 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 4 Jun 2021 10:50:49 +0800 Subject: [PATCH 3/4] Fix bug --- .../ApolloClient__Cache_InMemory_Policies_FieldPolicy.res | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res b/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res index 3a7c2f2..cc52d7e 100644 --- a/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res +++ b/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res @@ -56,7 +56,7 @@ module FieldFunctionOptions = { "canRead" @bs.send external readField: t => ReadFieldFunction.Js_.t = "readField" @bs.send - external toReference: (t, reference) => unit = "toReference" + external toReference: (t, reference) => string = "toReference" } type t = { @@ -66,7 +66,7 @@ module FieldFunctionOptions = { field: Js.nullable, variables: option>, isReference: bool, - toReference: (~typename: string, ~id: string) => unit, + toReference: (~typename: string, ~id: string) => string, storage: Js.nullable, cache: ApolloCache.t, readField: unimplemented, From ab32aea68ff3209587b08e1cbab579c916cef288 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 4 Jun 2021 10:52:12 +0800 Subject: [PATCH 4/4] Wrong order --- .../ApolloClient__Cache_InMemory_Policies_FieldPolicy.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res b/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res index cc52d7e..9bacec6 100644 --- a/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res +++ b/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res @@ -66,7 +66,7 @@ module FieldFunctionOptions = { field: Js.nullable, variables: option>, isReference: bool, - toReference: (~typename: string, ~id: string) => string, + toReference: (~id: string, ~typename: string,) => string, storage: Js.nullable, cache: ApolloCache.t, readField: unimplemented,