jeddeloh / rescript-apollo-client

ReScript bindings for the Apollo Client ecosystem
MIT License
126 stars 18 forks source link

Bind mocked provider #129

Closed Arnarkari93 closed 2 years ago

Arnarkari93 commented 2 years ago

What

Create <MockedProvider /> in rescript.

Why

How

jeddeloh commented 2 years ago

@Arnarkari93 I've got a couple questions on this PR. Is it ready for review?

arnar-sothebys commented 2 years ago

Yes, it's ready for review. Did you have some other approach to bind this in mind?

jeddeloh commented 2 years ago

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?

arnar-sothebys commented 2 years ago

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.

Arnarkari93 commented 2 years ago

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

jeddeloh commented 2 years ago

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.

arnar-sothebys commented 2 years ago

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.

jeddeloh commented 2 years ago

This is now published in v2.3.0. Thank you so much for working on this!