Closed Arnarkari93 closed 2 years ago
@Arnarkari93 I've got a couple questions on this PR. Is it ready for review?
Yes, it's ready for review. Did you have some other approach to bind this in mind?
Well, I haven't loaded up much in my head yet, but doesn't mocked provider use some react context to provide an apollo client? And in #112, you point out that the client needs these extra properties like rescript_query
on it. We then discussed possibly recreating MockedProvider
entirely in ReScript since it's not too large.
Are you saying we can just bind to MockedProvider
, though?
Ahh, now I remember what was. These bindings will be limited to testing components that use only hooks. If the component tries to directly perform an operation on the apollo client it will try to execute the rescript_query/rescript_mutate/rescript_subscribe
method on the client and that will fail.
I have updated the PR and recreated the MockedProvider
in rescript.
Official version is here: https://github.com/apollographql/apollo-client/blob/main/src/testing/react/MockedProvider.tsx
Thank you, this looks great! I'm going to merge a bit later today. If you want to add a comment in MockedProvider
about why we built it ourselves rather than binding, that would probably be good, but no worries if not. I'll do so after.
Thank you, this looks great! I'm going to merge a bit later today. If you want to add a comment in
MockedProvider
about why we built it ourselves rather than binding, that would probably be good, but no worries if not. I'll do so after.
Yes, no problem. I can add it now.
This is now published in v2.3.0. Thank you so much for working on this!
What
Create
<MockedProvider />
in rescript.Why
rescript_query
that are added to the client instance are available.Js.Json.t
so that we are writing to the apollo cache since cannot write variants to the cache.null
andundefined
when writing to the cache.None
translates toundefined
How
makeResult
method that takes intoJson
method that knows how to serialize back toJs.Json.t
. That method is generated as a part of the graphql ppx