Releases: jaydenseric/graphql-react
Version 20.0.0
Major
- Updated the
react-waterfall-renderdependency to v5.
Patch
- Updated the
extract-filesdependency to v13. - Updated dev dependencies.
- Use the
node:URL scheme for Node.js builtin module imports in tests. - Updated ESLint config.
- Replaced TypeScript
Recordtypes with index signatures. - Added missing readme “Installation” section import map instructions for
is-plain-obj. - Added Browserslist links to the readme.
- Tweaked the readme.
- Fixed broken links in the readme.
- Fixed a broken link in the v13.0.0 changelog entry.
Version 19.0.0
Major
- Updated Node.js support to
^14.17.0 || ^16.0.0 || >= 18.0.0.
Patch
- Updated the
reactpeer dependency to16.14 - 18. - Removed the redundant
react-dompeer dependency. - Updated dependencies.
- Removed the
@testing-library/react-hooksdev dependency and rewrote React hook tests usingreact-test-renderer, a new test utility functioncreateReactTestRenderer, and a custom React componentReactHookTest. - Removed the
fetch-blobandformdata-nodedev dependencies. Instead,FileandFormDataare imported fromnode-fetch. - Updated
jsconfig.json:- Set
compilerOptions.maxNodeModuleJsDepthto10. - Set
compilerOptions.moduletonodenext.
- Set
- Updated GitHub Actions CI config:
- Run tests with Node.js v14, v16, v18.
- Removed the now redundant
not IE > 0from the Browserslist query. - Updated
react-dom/serverimports in tests to suit React v18. - Fixed the
fetchGraphQLtest with the globalfetchAPI unavailable for new versions of Node.js that have thefetchglobal. - Use
globalThisinstead ofglobalin tests. - Use
ReactTestRendererinstead ofReactDOMServer.renderToStaticMarkupin some React context related tests. - Removed some unnecessary JSDoc comments in tests.
- Fixed some JSDoc links.
- Revamped the readme:
- Removed the badges.
- Updated the “Examples” section to reflect the
graphql-reactexamples repo migration from Node.js, Next.js, and Vercel to Deno, Ruck, and Fly.io. - Added information about Deno, import maps, TypeScript config, and optimal JavaScript module design.
Version 18.0.0
Major
- Renamed the type
FetchGraphQLResultErrorstoFetchGraphQLResultErrorinfetchGraphQL.mjs.
Minor
- Added the new type
FetchGraphQLResultErrorLoadingtofetchGraphQL.mjscontaining the GraphQL result error types related to loading that are generated on the client, not the GraphQL server.
Patch
- Updated dev dependencies.
- Simplified dev dependencies and config for ESLint.
- Updated GitHub Actions CI config.
- Fixed issues with GraphQL result related types from
types.mjs. - Improved various JSDoc descriptions.
- Improved the types relating to the
Deferredclass used in tests.
Version 17.0.0
Major
- Updated the
extract-filesdependency. - Updated the
react-waterfall-renderdependency. - Implemented TypeScript types via JSDoc comments, fixing #6.
Patch
- Updated dev dependencies.
- Sorted the contents of the package
filesandexportsfields. - Removed the
jsdoc-mddev dependency and the packagedocs-updateanddocs-checkscripts, replacing the readme “API” section with a manually written “Exports” section. - Check TypeScript types via a new package
typesscript. - Replaced the
formdata-nodedev dependency withformdata-polyfillandfetch-blob. - Updated GraphQL spec URLs in JSDoc and regular comments.
- Readme tweaks.
- Added a
license.mdMIT License file, fixing #54.
Version 16.0.0
Major
- Updated Node.js support to
^12.22.0 || ^14.17.0 || >= 16.0.0. - Updated dependencies, some of which require newer Node.js versions than previously supported.
- Public modules are now individually listed in the package
filesandexportsfields. - Removed
./packagefrom the packageexportsfield; the fullpackage.jsonfilename must be used in arequirepath. - Removed the package main index module; deep imports must be used.
- Shortened public module deep import paths, removing the
/public/. - The API is now ESM in
.mjsfiles instead of CJS in.jsfiles, accessible viaimportbut notrequire. - Switched back to using
React.createElementinstead of the the new React JSX runtime.
Patch
- Also run GitHub Actions CI with Node.js v17.
- Simplified package scripts.
- Removed the
isobjectdependency. - Refactored the
useCacheEntryPrunePreventionReact hook to avoid theReact.useCallbackReact hook. - Avoid named imports from
reactandreact-domas they’re not proper Node.js ESM. - Removed conditionality on the Node.js global
process.env.NODE_ENV. - Configured polyfilled globals in ESLint config for
eslint-plugin-compat. - Fixed JSDoc grammar typos.
- Reorganized the test file structure.
- Corrected a test name.
- Test the bundle sizes for public modules individually.
- Use a new
assertBundleSizefunction to assert module bundle size in tests:- Failure message contains details about the bundle size and how much the limit was exceeded.
- Errors when the surplus is greater than 25% of the limit, suggesting the limit should be reduced.
- Resolves the minified bundle and its gzipped size for debugging in tests.
- Configured Prettier option
singleQuoteto the default,false. - Documentation tweaks.
Version 15.0.0
Major
- Updated the
extract-filesdependency to v11. This dependency is used by the functionfetchOptionsGraphQL.
Patch
- Updated dev dependencies.
- Renamed imports in the test index module.
- Amended the changelog entries for v11.0.0, v11.0.2, and v14.0.0.
Version 14.0.0
Major
- Updated Node.js support to
^12.20 || >= 14.13. - Updated dependencies, some of which require newer Node.js versions than were previously supported.
- Replaced the the
package.jsonexportsfield public subpath folder mapping (deprecated by Node.js) with a subpath pattern. Deeprequirepaths withingraphql-react/public/must now include the.jsfile extension. - The tests are now ESM in
.mjsfiles instead of CJS in.jsfiles.
Patch
- Updated GitHub Actions CI config to run tests with Node.js v12, v14, v16.
- Simplified JSDoc related package scripts now that
jsdoc-mdv10+ automatically generates a Prettier formatted readme. - Added a package
test:jsdocscript that checks the readme API docs are up to date with the source JSDoc. - Test the bundle size using
esbuildinstead ofwebpackanddisposable-directory. - Increased the documented bundle size to “< 4 kB” to match that of
esbuildinstead ofwebpack. - Use the correct
kBsymbol instead ofKBwherever bundle size is mentioned in the package description and readme. - Don’t destructure
requirefromreactto slightly improve theesbuildbundle size. - Use the
.jsfile extension in internalrequirepaths. - Updated the example Next.js app URL in the readme.
- Readme tweaks.
- The file
changelog.mdis no longer published.
Version 13.0.0
Major
-
Updated Node.js version support to
^12.0.0 || >= 13.7.0. -
Stopped supporting Internet Explorer.
-
Updated the
reactandreact-dompeer dependencies to16.14 - 17. -
Use the new JSX runtime.
-
Reorganized the file structure and replaced the entire API:
- Removed all of the previous public exports for the old API:
GraphQLGraphQLContextGraphQLProviderhashObjectreportCacheErrorsuseGraphQLssr
- Added public exports for the new API, available as named imports from the index and as deep imports from
graphql-react/public/.jsCJS modules:CacheCacheContextHYDRATION_TIME_MSHydrationTimeStampContextLoadingLoadingCacheValueLoadingContextProvidercacheDeletecacheEntryDeletecacheEntryPrunecacheEntrySetcacheEntryStalecachePrunecacheStalefetchGraphQLfetchOptionsGraphQLuseAutoAbortLoaduseAutoLoaduseCacheuseCacheEntryuseCacheEntryPrunePreventionuseLoadGraphQLuseLoadOnDeleteuseLoadOnMountuseLoadOnStaleuseLoadinguseLoadingEntryuseWaterfallLoad
- The function
waterfallRenderfromreact-waterfall-rendershould now be used for server side rendering, fixing #57. - In addition to the previously required globals, consider polyfilling:
The API for the cache (centered around a
Cacheinstance provided in theCacheContextReact context) is separated from the API for loading (centered around aLoadinginstance provided in theLoadingContextReact context). Although the new loading system should work well for everyone, it could be totally avoided in an app that implements a custom alternative.Instead of using the old
mittdependency for events, theCacheandLoadingclasses extend the nativeEventTargetglobal available in modern browsers and Node.js; a powerful and familiar event system with zero bundle size cost.The new API avoids class methods that add to bundle size regardless if they are used, in favor of focused functions that can be imported to process instances as arguments. For example, one route in your app may only render a cache entry, while another may have a form that makes the global cache stale. If the functionality to make the cache stale was a
Cacheinstance method, it would increase the bundle size for the entire app, whereas a function imported in the second route will only grow the bundle size for that route. Features can be added to the API over time without growing everyone’s bundles.There are now functions that can be imported to directly manipulate the cache. The functions
cacheEntrySetandcacheEntryDeleteupdate a particular entry, andcacheDeletedeletes all cache.There is a new approach for dealing with stale cache. The function
cacheEntryStalesignals a single entry is stale, andcacheStaledoes the same for all entries (useful after a mutation). These functions don’t actually update cache entries; they simply dispatch cache entry stale events and it’s up to components to listen for this event and reload the cache entry in response, typically via theuseLoadOnStaleReact hook.Cache entries that are not relevant to the current view can now be pruned on demand using the functions
cacheEntryPrunefor a single entry, orcachePrunefor all entries, fixing #55. These functions work by dispatching cache entry prune events on theCacheinstance, and for each event not cancelled by a listener withevent.preventDefault(), the cache entry is deleted. TheuseCacheEntryPrunePreventionReact hook can be used to automatically cancel pruning of a cache entry used in a component.Cache keys are now manually defined instead of automatically derived from
fetchoptions hashes, fixing #56. This is easier to understand, is faster to render, and results in a smaller bundle size without the oldfnv1adependency for hashing.Instead of one
useGraphQLReact hook with complex options that all add to a component’s bundle size regardless if they are used, there are now several more focused React hooks that can be composed to do exactly the work required, fixing #53.The React hooks can be composed with custom ones to load and cache any type of data, not just GraphQL, using any method, not just
fetch.The new loading system provides the ability to abort loading at any time, implemented using the native
AbortControllerglobal available in modern browsers and Node.js, fixing #24. Many of the new React hooks leverage this for features such as automatically aborting loading a cache entry when the component loading it unmounts. The new API makes it trivially easy to build features as auto-suggest search inputs that abort the last loading on new input, or page queries that abort loading if the user abandons the route.While the new API may seem to have an intimidating number of public exports, the average Next.js app that queries and renders data from a GraphQL API will only use a few. For inspiration, see the readme “Examples” section.
- Removed all of the previous public exports for the old API:
-
Published modules now contain JSDoc comments, which might affect TypeScript projects.
Patch
- Updated dependencies.
- Removed Babel and related dependencies and config.
- Updated GitHub Actions CI config:
- Updated
actions/checkoutto v2. - Updated
actions/setup-nodeto v2. - Don’t specify the
CIenvironment variable as it’s set by default.
- Updated
- Stop using
hard-rejectionto detect unhandledPromiserejections in tests, as Node.js v15+ does this natively. - Test the bundle size manually using
webpackv5, and removesize-limitrelated dev dependencies, config, and scripts. - Tweaked the package description.
- Readme edits, including:
- Updated the Relay and Apollo URLs.
- Mention polyfilling any required globals in the “Setup” section.
- Removed the “Usage” section.
- Tweaked links in the “Support” section.
- Removed the “Apollo comparison” section.
Version 12.0.1
Version 12.0.0
Major
-
Concurrent GraphQL operations with the same cache key no longer share the first request.
-
The
GraphQLinstance propertyoperationstype has changed:- object<GraphQLCacheKey, Promise<GraphQLCacheValue>> + object<GraphQLCacheKey, Array<Promise<GraphQLCacheValue>>>
Patch
- Updated dev dependencies.
- Improved the test utility
promisifyEventfunction. - Test the the
GraphQLinstance methodoperateoptionreloadOnLoadin isolation. - Test better the order of the
GraphQLinstance methodoperatetriggered events. - Refactored the
GraphQLinstance methodoperateto eliminate theGraphQLprivate instance methodfetchand reduce the chance of race conditions in consumer code. - Reduced the number of promises created by the
GraphQLinstance methodoperatewhen thereloadOnLoadandreloadOnLoadoptions arefalse. - Added a code example for how to await all loading GraphQL operations.
- Used consistent JSDoc types for promises that resolve
void. - Tweaked JSDoc.
- Tweaked changelog entries.