Releases: jeddeloh/rescript-apollo-client
v2.1.2
v2.1.1
v2.1.0
v2.0.1
v1.1.2
v1.1.1
v1.1.0
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__ApolloClientfile moved toApolloClient__Core_ApolloClient - (unlikely)
Observable.tandObservable.Js_.tare no longer interchangeable
Features
QueryResult.tnow contains apreviousDatapropertysubscribemethod added toApolloClient.t
v1.0.0
⚠️ Now published asrescript-apollo-client!
Breaking Changes
bs-platformdependency updated to^8.2.0since the source code is now in ReScript (there is a v1.0.0 published underreason-apollo-clientif you are still on an older version of BuckleScript)- An internal variant
parseResult(rarely exposed) converted to normalresult readFragmentandreadQuerycache methods return a result rather than throwing exception
v1.0.0-beta.1
Bug Fixes
- Extra validation on
ApolloError(there is no validation in @apollo/client so we have to do it) readFragmentmethods on cache and client were not getting parsed
v1.0.0-beta.0
Breaking Changes
- Methods are now located directly on the record. Previously, they were functions in the type modules.
graphql-ppxparse 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
resultif they can fail. - Improved return values of promises (
Okdefinitely has some form of data, and all other cases are moved to theErrorvariant) ApolloError.tis used exclusively across the library instead of sayerrors: array(GraphQLError.t). This allows us to express more types of errors, like a parse failure mentioned above.
Features
- Added
readFragmentmethods
Bug Fixes
- Fixed
NetworkStatusbindings - Fixed some methods still expecting
graphql-ppxRaw.t_variablesinsteadt_variables - Made variables on
refetchoptional
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.