Skip to content

Releases: jeddeloh/rescript-apollo-client

v2.1.2

01 Sep 13:40

Choose a tag to compare

Bug Fixes

  • Missing nextFetchPolicy on WatchQueryOptions

v2.1.1

31 Aug 18:36

Choose a tag to compare

Bug Fixes

  • Fixed missing nextFetchPolicy arg on use within extended graphql-ppx modules

v2.1.0

11 Jul 22:18
d75edfd

Choose a tag to compare

Features

  • Added bindings for RetryLink: #119
  • Added missing nextFetchPolicy on QueryHookOptions and LazyQueryHookOptions: #120

Bug Fixes

  • Fixed unintended currying when calling forward in ErrorLink: #118

v2.0.1

02 May 15:34
55934a8

Choose a tag to compare

Breaking Changes

  • reason-react dependency changed to @rescript/react

Features

  • bs-platform is now an optional dependency so you can use rescript or melange or whatever

v1.1.2

27 Apr 01:24

Choose a tag to compare

Features

  • subscribeToMore now returns an unsubscribe function

v1.1.1

12 Feb 16:23

Choose a tag to compare

Bug Fixes

  • The internal raw JS function ensureApolloError no longer throws an error due to missing argument
  • docs/ directory removed from npm package
  • bs-platform peer dependency updated to allow v9+

v1.1.0

04 Feb 20:17

Choose a tag to compare

Peer Dependency Updates

  • @apollo/client: ^3.3.0. This is not a breaking change, but needed for new functionality. Open an issue if you think this should have been a major version bump (I don't).

Breaking Changes

  • (unlikely) ApolloClient__ApolloClient file moved to ApolloClient__Core_ApolloClient
  • (unlikely) Observable.t and Observable.Js_.t are no longer interchangeable

Features

  • QueryResult.t now contains a previousData property
  • subscribe method added to ApolloClient.t

v1.0.0

19 Dec 17:09

Choose a tag to compare

⚠️ Now published as rescript-apollo-client!

Breaking Changes

  • bs-platform dependency updated to ^8.2.0 since the source code is now in ReScript (there is a v1.0.0 published under reason-apollo-client if you are still on an older version of BuckleScript)
  • An internal variant parseResult (rarely exposed) converted to normal result
  • readFragment and readQuery cache methods return a result rather than throwing exception

v1.0.0-beta.1

04 Nov 23:32

Choose a tag to compare

Bug Fixes

  • Extra validation on ApolloError (there is no validation in @apollo/client so we have to do it)
  • readFragment methods on cache and client were not getting parsed

v1.0.0-beta.0

16 Oct 13:35
5d5614b

Choose a tag to compare

Breaking Changes

  • Methods are now located directly on the record. Previously, they were functions in the type modules.
  • graphql-ppx parse functions are now safely wrapped so they return a result instead of allowing exceptions to escape the library (this is mostly transparent change because they are usually unwrapped at some point into an ApolloError if necessary).
  • Promise returning methods changed to return a result if they can fail.
  • Improved return values of promises (Ok definitely has some form of data, and all other cases are moved to the Error variant)
  • ApolloError.t is used exclusively across the library instead of say errors: array(GraphQLError.t). This allows us to express more types of errors, like a parse failure mentioned above.

Features

  • Added readFragment methods

Bug Fixes

  • Fixed NetworkStatus bindings
  • Fixed some methods still expecting graphql-ppx Raw.t_variables instead t_variables
  • Made variables on refetch optional

Overview

Just like JavaScript!

Methods are now called directly from records or destructured. This should make for an easier transition for anyone coming from JavaScript as well as make things more discoverable and consistent.

  let queryResult = TodosQuery.use();

  <div>
    {switch (queryResult) {
     | {loading, data, error, fetchMore} =>
...

Improved promise return values

Promises now return a result and will not reject. However, it's very common to forget to check for graphql errors when you're presented with an Ok/Error result. For this reason we're now a little smarter and we unwrap the case where you definitely have data, and everything else into error:

client.query(~query=(module TodosQuery), ())
|> Js.Promise.then_(result =>
    switch (result) {
    | Ok({data: {todos}, error: None}) =>
      // You can't be Ok with data: None
    | Ok({data: {todos}, error: Some(error)}) =>
      // You _can_ have data and error, but only if you change error policy from default to "all"
    | Error(error) =>
      // Any other case is an error:
      // - 200 response with graphqlErrors and no data (always if errorPolicy is "none", the default)
      // - fetch error, etc.
      // - no data and no error (impossible?)
    }
  );

Parsing will no longer raise exceptions (mostly transparent change)

All parse functions now safely converted to result returning functions. For the vast majority of cases, Apollo returns a "result" of some type anyway so we unwrap the result and convert to an appropriate error representation. There are a few cases where this is not possible (like parsing previous values from the cache) so you have to deal with a result but I think in the end this is a good tradeoff.