- Updated Node.js support to
^18.18.0 || ^20.9.0 || >=22.0.0
. - Use the Node.js test runner API and remove the dev dependency
test-director
. - Refactored tests to use the standard
AbortController
,AbortSignal
,Event
,EventTarget
,File
,FormData
, andResponse
APIs available in modern Node.js and removed the dev dependenciesabort-controller
,event-target-shim
, andnode-fetch
. - Use the TypeScript v5.5+ JSDoc tag
@import
to import types in modules.
- Updated dev dependencies.
- Updated the
package.json
fieldrepository
to conform to new npm requirements. - Updated GitHub Actions CI config:
- No longer run the workflow on pull request.
- Enable manual workflow dispatching.
- Run tests with Node.js v18, v20, v22.
- Updated
actions/checkout
to v4. - Updated
actions/setup-node
to v4.
- Updated the
react-waterfall-render
dependency to v5.
- Updated the
extract-files
dependency to v13. - Updated dev dependencies.
- Use the
node:
URL scheme for Node.js builtin module imports in tests. - Updated ESLint config.
- Replaced TypeScript
Record
types 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.
- Updated Node.js support to
^14.17.0 || ^16.0.0 || >= 18.0.0
.
- Updated the
react
peer dependency to16.14 - 18
. - Removed the redundant
react-dom
peer dependency. - Updated dependencies.
- Removed the
@testing-library/react-hooks
dev dependency and rewrote React hook tests usingreact-test-renderer
, a new test utility functioncreateReactTestRenderer
, and a custom React componentReactHookTest
. - Removed the
fetch-blob
andformdata-node
dev dependencies. Instead,File
andFormData
are imported fromnode-fetch
. - Updated
jsconfig.json
:- Set
compilerOptions.maxNodeModuleJsDepth
to10
. - Set
compilerOptions.module
tonodenext
.
- Set
- Updated GitHub Actions CI config:
- Run tests with Node.js v14, v16, v18.
- Removed the now redundant
not IE > 0
from the Browserslist query. - Updated
react-dom/server
imports in tests to suit React v18. - Fixed the
fetchGraphQL
test with the globalfetch
API unavailable for new versions of Node.js that have thefetch
global. - Use
globalThis
instead ofglobal
in tests. - Use
ReactTestRenderer
instead ofReactDOMServer.renderToStaticMarkup
in 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-react
examples 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.
- Renamed the type
FetchGraphQLResultErrors
toFetchGraphQLResultError
infetchGraphQL.mjs
.
- Added the new type
FetchGraphQLResultErrorLoading
tofetchGraphQL.mjs
containing the GraphQL result error types related to loading that are generated on the client, not the GraphQL server.
- 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
Deferred
class used in tests.
- Updated the
extract-files
dependency. - Updated the
react-waterfall-render
dependency. - Implemented TypeScript types via JSDoc comments, fixing #6.
- Updated dev dependencies.
- Sorted the contents of the package
files
andexports
fields. - Removed the
jsdoc-md
dev dependency and the packagedocs-update
anddocs-check
scripts, replacing the readme “API” section with a manually written “Exports” section. - Check TypeScript types via a new package
types
script. - Replaced the
formdata-node
dev dependency withformdata-polyfill
andfetch-blob
. - Updated GraphQL spec URLs in JSDoc and regular comments.
- Readme tweaks.
- Added a
license.md
MIT License file, fixing #54.
- 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
files
andexports
fields. - Removed
./package
from the packageexports
field; the fullpackage.json
filename must be used in arequire
path. - 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
.mjs
files instead of CJS in.js
files, accessible viaimport
but notrequire
. - Switched back to using
React.createElement
instead of the the new React JSX runtime.
- Also run GitHub Actions CI with Node.js v17.
- Simplified package scripts.
- Removed the
isobject
dependency. - Refactored the
useCacheEntryPrunePrevention
React hook to avoid theReact.useCallback
React hook. - Avoid named imports from
react
andreact-dom
as 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
assertBundleSize
function 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
singleQuote
to the default,false
. - Documentation tweaks.
- Updated the
extract-files
dependency to v11. This dependency is used by the functionfetchOptionsGraphQL
.
- 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.
- 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.json
exports
field public subpath folder mapping (deprecated by Node.js) with a subpath pattern. Deeprequire
paths withingraphql-react/public/
must now include the.js
file extension. - The tests are now ESM in
.mjs
files instead of CJS in.js
files.
- Updated GitHub Actions CI config to run tests with Node.js v12, v14, v16.
- Simplified JSDoc related package scripts now that
jsdoc-md
v10+ automatically generates a Prettier formatted readme. - Added a package
test:jsdoc
script that checks the readme API docs are up to date with the source JSDoc. - Test the bundle size using
esbuild
instead ofwebpack
anddisposable-directory
. - Increased the documented bundle size to “< 4 kB” to match that of
esbuild
instead ofwebpack
. - Use the correct
kB
symbol instead ofKB
wherever bundle size is mentioned in the package description and readme. - Don’t destructure
require
fromreact
to slightly improve theesbuild
bundle size. - Use the
.js
file extension in internalrequire
paths. - Updated the example Next.js app URL in the readme.
- Readme tweaks.
- The file
changelog.md
is no longer published.
-
Updated Node.js version support to
^12.0.0 || >= 13.7.0
. -
Stopped supporting Internet Explorer.
-
Updated the
react
andreact-dom
peer 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:
GraphQL
GraphQLContext
GraphQLProvider
hashObject
reportCacheErrors
useGraphQL
ssr
- Added public exports for the new API, available as named imports from the index and as deep imports from
graphql-react/public/
.js
CJS modules:Cache
CacheContext
HYDRATION_TIME_MS
HydrationTimeStampContext
Loading
LoadingCacheValue
LoadingContext
Provider
cacheDelete
cacheEntryDelete
cacheEntryPrune
cacheEntrySet
cacheEntryStale
cachePrune
cacheStale
fetchGraphQL
fetchOptionsGraphQL
useAutoAbortLoad
useAutoLoad
useCache
useCacheEntry
useCacheEntryPrunePrevention
useLoadGraphQL
useLoadOnDelete
useLoadOnMount
useLoadOnStale
useLoading
useLoadingEntry
useWaterfallLoad
- The function
waterfallRender
fromreact-waterfall-render
should 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
Cache
instance provided in theCacheContext
React context) is separated from the API for loading (centered around aLoading
instance provided in theLoadingContext
React 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
mitt
dependency for events, theCache
andLoading
classes extend the nativeEventTarget
global 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
Cache
instance 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
cacheEntrySet
andcacheEntryDelete
update a particular entry, andcacheDelete
deletes all cache.There is a new approach for dealing with stale cache. The function
cacheEntryStale
signals a single entry is stale, andcacheStale
does 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 theuseLoadOnStale
React hook.Cache entries that are not relevant to the current view can now be pruned on demand using the functions
cacheEntryPrune
for a single entry, orcachePrune
for all entries, fixing #55. These functions work by dispatching cache entry prune events on theCache
instance, and for each event not cancelled by a listener withevent.preventDefault()
, the cache entry is deleted. TheuseCacheEntryPrunePrevention
React 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
fetch
options hashes, fixing #56. This is easier to understand, is faster to render, and results in a smaller bundle size without the oldfnv1a
dependency for hashing.Instead of one
useGraphQL
React 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
AbortController
global 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.
- Updated dependencies.
- Removed Babel and related dependencies and config.
- Updated GitHub Actions CI config:
- Updated
actions/checkout
to v2. - Updated
actions/setup-node
to v2. - Don’t specify the
CI
environment variable as it’s set by default.
- Updated
- Stop using
hard-rejection
to detect unhandledPromise
rejections in tests, as Node.js v15+ does this natively. - Test the bundle size manually using
webpack
v5, and removesize-limit
related 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.
- Updated the
react
andreact-dom
peer dependencies to16.8 - 17
. - Updated dependencies.
- Also run GitHub Actions with Node.js v15.
-
Concurrent GraphQL operations with the same cache key no longer share the first request.
-
The
GraphQL
instance propertyoperations
type has changed:- object<GraphQLCacheKey, Promise<GraphQLCacheValue>> + object<GraphQLCacheKey, Array<Promise<GraphQLCacheValue>>>
- Updated dev dependencies.
- Improved the test utility
promisifyEvent
function. - Test the the
GraphQL
instance methodoperate
optionreloadOnLoad
in isolation. - Test better the order of the
GraphQL
instance methodoperate
triggered events. - Refactored the
GraphQL
instance methodoperate
to eliminate theGraphQL
private instance methodfetch
and reduce the chance of race conditions in consumer code. - Reduced the number of promises created by the
GraphQL
instance methodoperate
when thereloadOnLoad
andreloadOnLoad
options 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.
- Added a new
cacheKeyCreator
option to theGraphQL
instance methodoperate
and theuseGraphQL
React hook. - The previously private
hashObject
function is now publicly exported.
- Replaced Node.js deprecated
notEqual
assertions withnotStrictEqual
in tests. - Use the
TypeError
class instead ofError
for relevant errors.
- Allow React component
displayName
andpropTypes
to be removed in production builds, fixing #51. - Refactored the
useGraphQL
React hook to do less work for following renders if theoperation
andfetchOptionsOverride
options are defined outside the component or memoized using theReact.useMemo
hook. - Memoize what the
useGraphQL
React hook returns for more efficient hook composition. - Added a new
loadedCacheValue
property to the GraphQL operation status object returned by theuseGraphQL
React hook. This allows cache for an earlier operation to be rendered while loading changes to the query, variables, orfetch
options.
- Updated dependencies.
- Use
coverage-node
to enforce 100% code coverage for tests. - Increased the universal API size-limit from 3 KB to 3.5 KB.
- Updated the
useGraphQL
React hook examples to use the GitHub GraphQL API. - Improved the
useGraphQL
React hook tests. - Improved documentation.
- Clearly documented ways to
import
andrequire
the package exports.
- Updated the
extract-files
dependency to v9.0.0, and used its new deeprequire
path. - Updated dev dependencies.
- No longer test Node.js v13 in GitHub Actions CI.
- Corrected the Browserslist query in the Babel config for the server API.
- Write tests as CJS and no longer separately build and test ESM and CJS to simplify package scripts, Babel and ESLint config.
- Removed the
@babel/plugin-proposal-class-properties
dev dependency and config, as@babel/preset-env
has handed this via it’sshippedProposals
options since v7.10.0. - Removed unnecessary
.js
file extensions fromrequire
paths. - Improved polyfilling globals in tests:
- Use
revertable-globals
to define globals per-test. - Use
node-fetch
v3 instead ofcross-fetch
.
- Use
- Removed a no longer necessary
formdata-node
workaround ingraphqlFetchOptions
tests. - Removed
npm-debug.log
from the.gitignore
file as npm v4.2.0+ doesn’t create it in the current working directory.
- Updated dependencies.
- Simplified the GitHub Actions CI config with the
npm install-test
command. - Use Babel config
overrides
to ensure.js
files are parsed as scripts, eliminating BabelinteropRequireDefault
helpers from transpilation output. - Updated Zeit/Vercel related URLs in documentation.
- Updated the readme “Apollo comparison” section.
- Updated Node.js support to
^10.17.0 || ^12.0.0 || >= 13.7.0
. This is only a correction; the dependency updates with breaking changes happened in previous versions. - Updated dependencies.
- Simplified JSX boolean props in tests.
- Improved event documentation.
- Fixed an incorrect
reportCacheErrors
JSDoc parameter type. - Updated EditorConfig.
- Added a package
exports
field to support native ESM in Node.js. - Some source and published files are now
.js
(CJS) instead of.mjs
(ESM), so undocumented deep imports may no longer work. This approach avoids the dual package hazard. - Updated Node.js support from v10+ to
10 - 12 || >= 13.7
to reflect the packageexports
related breaking changes.
- Updated dependencies.
- Added a new
babel-plugin-transform-runtime-file-extensions
dev dependency to simplify Babel config. - Improved the package
prepare:prettier
andtest:prettier
scripts. - Reordered the package
test:eslint
script args for consistency withtest:prettier
. - Configured Prettier option
semi
to the default,true
. - Reconfigured
size-limit
:- Separately test the universal and server only exports, without using unpublished size limit entry files that bloat the measured sizes.
- Separately test the ESM and CJS exports.
- Separately limit tests, with the universal ESM and CJS set to a 3 KB maximum size.
- Removed redundant ESLint disable comments.
- Also run GitHub Actions with Node.js v14.
- Updated readme content.
- Updated JSDoc code examples:
- Prettier formatting.
- Import React in examples containing JSX.
- Use Node.js ESM compatible import specifiers.
- Updated Node.js support from v8.10+ to v10+.
- Updated dependencies, some of which require Node.js v10+.
- Replaced the
tap
dev dependency withtest-director
andhard-rejection
, and refactored tests accordingly. This improves the dev experience and reduced the dev install size by ~75.5 MB. - Use
ReactDOM.unstable_batchedUpdates
in theuseGraphQL
React hook to reduce the number of renders when loading completes, fixing #38 via #42. Althoughreact-dom
was already a peer dependency, this is the first time it's being used in the client API; potentially a breaking change for atypical projects.
- Updated tests for compatibility with updated dependencies.
- Removed the
object-assign
dependency and several Babel dev dependencies after simplifying the Babel config. - Added a new
babel-plugin-transform-require-extensions
dev dependency and ensured ESM import specifiers in both source and published.mjs
files contain file names with extensions, which are mandatory in the final Node.js ESM implementation. Published CJS.js
files now also have file extensions inrequire
paths. - Stop using
husky
andlint-staged
. - Lint fixes for
prettier
v2. - Tidied Babel configs.
- Ensure GitHub Actions run on pull request.
- Use strict mode for scripts.
- Readme “Apollo comparison” section corrections and tweaks.
- Setup GitHub Sponsors funding:
- Added
.github/funding.yml
to display a sponsor button in GitHub. - Added a
package.json
funding
field to enable npm CLI funding features.
- Added
- Updated dev dependencies.
- Updated Node.js support from v8.5+ to v8.10+, to match what the
eslint
dev dependency now supports. This is unlikely to be a breaking change for the published package. - The
useGraphQL
React hookloadOnMount
,loadOnReload
, andloadOnReset
options now default tofalse
instead oftrue
. The loading related options are now all opt-in, which is easier to remember and simpler to configure for situations that previously required manual reversal of certain option defaults. It's also safer when working with mutations you don't want to accidentally load.
- Updated dependencies.
- Replaced the
size-limit
dev dependency with@size-limit/preset-small-lib
. - Fixed the
useGraphQL
enabled optionloadOnReload
causing a load when the globalGraphQL
cache is reloaded even if there was no previously cached data to reload. - Tweaked the
useGraphQL
optionloadOnReset
documentation. - Removed
package-lock.json
from.gitignore
and.prettierignore
as it’s disabled in.npmrc
anyway. - Removed redundant ESLint ignore comments.
- Use GitHub Actions instead of Travis for CI.
- Minor simplification in
useGraphQL
tests. - Documentation improvements, fixing #35:
- Updated the project description with better phrasing that includes the bundle size.
- Moved the readme “Apollo comparison” section to the end, and updated the “Bundle impact” subsection for the new Apollo React hooks API.
- Added a basic example of the core API features working together to the “Examples” section, with tips commented.
- Clarified that Opera Mini isn’t supported in the Browserslist queries and readme “Support” section.
- Cleaner readme “API” section table of contents with “See” and “Examples” headings excluded, thanks to
jsdoc-md
v3.1.0.
- Added a
response
property to theGraphQL
instancecache
event payload, containing the originalfetch
Response
instance thecacheValue
was derived from.
- Updated dependencies.
- Increased the post SSR hydration time from 500 to 1000 milliseconds, closing #37.
- Added a
useGraphQL
options guide for common situations. - Test the
GraphQL
instance methodoperate
with bothreloadOnLoad
andresetOnLoad
optionstrue
. - Use string
FormData
field names, as someFormData
polyfills don't coerce numbers like native implementations do. - Test files in variables result in appropriate fetch options for a valid GraphQL multipart request.
- Tidied test names.
- Nicer Browserslist syntax for supported Node.js versions.
- Added a new
GraphQLProvider
component that prevents unnecessary loading on the client after SSR, fixing #4. This component should be used instead of usingGraphQLContext.Provider
directly. The old way still works, but with the old behavior.
- Updated dev dependencies.
- Updated the
GraphQLContext.Consumer
example to use React hooks.
- Updated dependencies.
- Adopted the new
size-limit
config file name. - Slightly faster
useGraphQL
render error when optionsreloadOnLoad
andresetOnLoad
are bothtrue
. - Use a ref instead of a variable in
useGraphQL
to track mounted status for cache related callbacks. - Document the
GraphQL
instance methodoperate
optionreloadOnLoad
. - Minor readme quotes consistency tweak.
- Updated dependencies.
- Updated
useGraphQL
to useuseCallback
and added hook dependency arrays, to fix a recently appearingreact-hooks/exhaustive-deps
lint error and hopefully reduce render work. - Reduced the size of the published
package.json
by moving dev tool config to files. This also prevents editor extensions such as Prettier and ESLint from detecting config and attempting to operate when opening package files installed innode_modules
. - Discuss Apollo Client fragment matcher config in the “Apollo comparison” readme section.
- Updated a dev dependency.
- Removed redundant
useGraphQL
internaluseEffect
React hook second arguments. - Fixed “Can't perform a React state update on an unmounted component” warnings if the component using the
useGraphQL
React hook is unmounted soon after anGraphQL
instance event such asreset
is emitted.
- Added the
GraphQL
instance methodreload
which fires areload
event signaling that GraphQL cache subscribers such as theuseGraphQL
React hook should reload their GraphQL operation, fixing #26. - Added the
useGraphQL
React hookreloadOnLoad
option.
- Updated dependencies.
- More reliable
useGraphQL
React hookloadOnMount
option implementation that fixes ESLintreact-hooks/exhaustive-deps
rule errors. - Use
function
instead ofconst
declarations in places to simplify transpiled output. GraphQL.reset()
test name typo fix.- Added tests for the
useGraphQL
React hookreloadOnLoad
andresetOnLoad
options. - Increased the browser bundle size limit to 2.5 KB as the new features grew the bundle size from ~1.95 KB to ~2.13 KB.
- Improved
GraphQL
instance event documentation.
- Updated dev dependencies.
useGraphQL
React hook bug fix for when arguments change after the initial render and theload
function is called:loading
andcacheValue
now update correctly after the operation loads.
- Updated dev dependencies.
useGraphQL
React hook bug fixes for when arguments change after the initial render:- Changes that cause the
cacheKey
to change trigger a reload if theloadOnMount
option istrue
, fixing #23. - Fixed stale operation status properties being returned.
- Changes that cause the
- Use
react-test-renderer
to testuseGraphQL
with a lot more detail. - Capitalized the
React
namespace inuseGraphQL
. - Improved
hashObject()
tests.
-
Updated the
react
andreact-dom
peer dependencies to^16.8.0
. -
Removed the
Query
component. -
No longer exporting
Provider
andConsumer
; nowGraphQLContext
is exported. -
The
GraphQL
instance methodquery
has been renamedoperate
. -
The
GraphQL
constructor no longer has thelogErrors
option, and GraphQL operation errors are no longer console logged by default. -
The
ssr
function is now exported fromgraphql-react/server
instead ofgraphql-react/lib/ssr
. -
The
ssr
function is now implemented usingasync
/await
syntax. -
Browser (and less commonly server) environments that fetch GraphQL operations with file uploads must now support (natively or by polyfill) the
FormData.entries()
API.Caching of GraphQL multipart requests when the
fetch
optionsbody
is aFormData
instance has been improved. Previously they would overwrite each other in the cache even if the GraphQL operations were different, depending if theFormData
instance was native or from a polyfill that could be JSON serialized.There is still room to improve as
FormData
field values that areFile
orBlob
instances don’t influence the cache key hashing. -
GraphQL
event properties have been renamed or added:- The
fetch
event propertyfetchOptionsHash
was renamedcacheKey
, and the propertycache
was renamedcacheValuePromise
. - The
cache
event propertyfetchOptionsHash
was renamedcacheKey
, and the propertycacheValue
was added. - The
reset
event propertyexceptFetchOptionsHash
was renamedexceptCacheKey
.
- The
- Added the
useGraphQL
React hook, which assumes the role of the removedQuery
component. - Documented the
GraphQL
on
andoff
methods for managing event listeners. - Added the
reportCacheErrors
function, aGraphQL
cache
event handler that can be setup to report GraphQL operation errors viaconsole.log()
.
- Updated dev dependencies.
- Updated the package description and keywords.
- Simplified the
prepublishOnly
script. - Use the
tap
CLI and default reporter for tests. - New project directory structure.
- Separate Babel configs for optimal universal, server, and test environment code.
- Much improved tests.
- Run size limit tests last in the package
test
script as they are the slowest. - Smaller package size limits for server (3 KB down to 2.5 KB) and browser (2.5 KB down to 2 KB) environments.
- Improved JSDoc types and API documentation.
- Updated the readme intro and added a new “Apollo comparison” section.
- Removed the
preload
function. It was not going to work with React hooks. - Added the
react-dom
peer dependency. - Reorganized file structure. This is only a breaking change for consumers that were not importing the documented way (via the
main
package entry).
- Added a
ssr
function, which is for server use only and is React hooks ready. It is simpler and more future-proof than the removedpreload
function as it leveragesReactDOMServer
for rendering. GraphQL
now emits acache
promise in thefetch
event payload. These events are undocumented, so this could be considered an internal change.
- Updated dependencies.
- Handle exceptions outside tests (see tapjs/node-tap#463 (comment)).
- Added a
ReactNode
JSDoc type, replacingReactElement
types. - Removed tests made redundant by the removal of the
preload
function. - Document the official Next.js example.
- Improved documentation.
- Updated dev dependencies.
- Removed the
watch
dev dependency andwatch
package script. preload
now properly catches render errors nested underQuery
components.preload
now supports class components that don’t call their base constructor withprops
, fixing #17.- Fixed a prop type warning in one of the tests.
- Fixed example code typos in the readme “Usage” section.
- Fixed incorrect
graphQLErrors
JSDoc type.
- Made
preload
reject upon render errors instead of throwing.
- Made
Query
component throw a helpful render error if the GraphQL context is missing.
- Updated dev dependencies.
- Improved
size-limit
tests:- Drop the CJS entrypoint; modern bundlers don’t use it and nested module imports revert resolve ESM anyway.
- Ignore
prop-types
since it’s likely to already be present in a React project, and most frameworks strip it out in production bundles anyway. - Separately limit and test server and client bundles.
- Updated the
extract-files
dependency to v5:- The original operation object is no longer modified when it contains files.
- If the same file is used in multiple locations of an operation it is only uploaded once.
- Updated dependencies.
- Removed a redundant
.prettierignore
entry. - Added tests for the internal
graphqlFetchOptions
function.
- Added a new
GraphQL
constructor optionlogErrors
(defaulttrue
) and instance property, controlling if GraphQL request errors should be console logged for easy debugging.
- Updated dependencies.
- Refactored
GraphQL
static methods to separate modules. - Moved JSDoc type definitions into the index file.
- Manually composed package exports instead of relying on
*
. - More consistent object snapshots in tests.
- Support more browsers by changing the Browserslist query from
> 1%
to> 0.5%, not dead
.
- Updated dependencies.
- Fix Babel not reading from the package
browserslist
field due to a sneaky@babel/preset-env
breaking change. - Add back the bundle size test accidentally removed in v4.0.1.
- Fixed
preload
forproduction
NODE_ENV
, fixing #11 and #12. preload
now scopes context under providers.- Removed redundant uses of
this
in the internalGraphQLQuery
component constructor. - Test the library with undefined and
production
NODE_ENV
.
- Updated the
react
peer dependency to^16.6.0
. - Fixed
preload
broken due to the React v16.6.0 context API change, fixing #11.
- Updated dev dependencies.
- The
Query
(and the internalGraphQLQuery
) component take anoperation
prop instead of separatevariables
andquery
props. This makes the implementation a little more elegant, is more consistent with theGraphQL.query
API and allows sending custom GraphQL operation fields. - New internal event system, fixing #10. Now the
loading
parameter ofQuery
component render functions change when identical requests are loaded elsewhere in the app.
- Improved
Provider
andConsumer
component display names in React dev tools:Context.Provider
→GraphQLContext.Provider
Context.Consumer
→GraphQLContext.Consumer
- Updated dependencies.
- Updated package scripts and config for the new
husky
version. - Removed the package
module
field. By default webpack resolves extensionless paths the same way Node.js in--experimental-modules
mode does;.mjs
files are preferred. Tools misconfigured or unable to resolve.mjs
can get confused whenmodule
points to an.mjs
ESM file and they attempt to resolve named imports from.js
CJS files. - Renamed the
Operation
typeGraphQLOperation
. - Use jsDelivr for the readme logo instead of RawGit as they are shutting down.
- Updated dependencies.
- Remove the
GraphQLQuery
component from API documentation as it used internally and is not exported. - Regenerated the readme API docs using the latest
jsdoc-md
version. - Added a new “Usage” readme section.
- Fixed a link in the readme.
- Fixed example GraphQL query typos.
- Updated Node.js support from v7.6+ to v8.5+.
- Use package
prepare
script to support installation via Git (e.g.npm install jaydenseric/graphql-react
). - Use
@babel/plugin-transform-runtime
and@babel/runtime
to make runtime helpers more DRY. Bundle size savings will manifest once more packages import the same helpers. - Package marked side-effect free for bundlers and tree-shaking.
- Updated dependencies.
- Removed the
rimraf
dev dependency in favour of a nativerm -rf
package clean script. Leaner and faster; we only support *nix for contributing anyway. - Fixed new Prettier lint errors and removed the
fake-tag
dev dependency now that Prettier can format template literals tagged with/* GraphQL */
. - Stopped using
npm-run-all
for package scripts to reduce complexity and bugs. - Compact package
repository
field. - Added more package tags.
- Lint
.yml
files. - Test with
graphql-api-koa
instead ofexpress-graphql
. - Fixed test snapshot consistency between Node.js versions (see tapjs/node-tap#450).
- Use
jsdoc-md
instead ofdocumentation
to generate readme API docs. - JSDoc fixes and improvements.
- Readme badge changes to deal with shields.io unreliability:
- Used the more reliable build status badge provided by Travis, configured to only track
master
branch. - Removed the licence badge. The licence can be found in
package.json
and rarely changes. - Removed the Github issues and stars badges. The readme is most viewed on Github anyway.
- Use Badgen for the npm version badge.
- Used the more reliable build status badge provided by Travis, configured to only track
- Updated dependencies.
- Fixed accidental distribution code Prettier ignoring.
- Replaced
ava
withtap
for testing. Tests don't require a special CLI, no longer transpile on the fly, are faster and AVA no longer dictates the Babel version. - Tests run against the actual dist
.mjs
and.js
files in native ESM (--experimental-modules
) and CJS environments. - Ignore
object-assign
for bundle size tests as it’s a React dependency and tighten the allowed bundle size from 4 KB to 3 KB. - Updated Babel config:
- Use
babel.config.js
instead of.babelrc.js
. - Renamed the
ESM
environment variable toBABEL_ESM
to be more specific.
- Use
- Improved
package.json
scripts:- Leveraged
npm-run-all
more for parallelism and reduced noise. - Removed linting fix scripts.
- Linting included in the
test
script. Travis CI will fail PR's with lint errors. - Custom watch script.
- No longer use
cross-env
; contributors with Windows may setup and use a Bash shell.
- Leveraged
- Improved ESLint config:
- Use eslint-config-env.
- Removed redundant
eslint-plugin-ava
dev dependency and config. - Undo overriding ESLint ignoring dotfiles by default as there are none now.
- Moved the example project to a separate repo.
- Better readme logo alt text.
- Capitalized the fetch options
Accept
header for display consistency in tools such as the Chrome network inspector and to better support case-sensitive systems, even though HTTP headers are supposed to be case-insensitive.
- Updated dependencies.
- Pinned
@babel
dev dependencies to match new AVA requirements. - Use
eslint-config-prettier
. - Readme example link goes to the example project directory instead of the readme file.
- Test and example updates:
- Use
fake-tag
for GraphQL template literals due to prettier/prettier#4360. - Use
express
instead of Koa packages. - Use
express-graphql
instead of Apollo packages.
- Use
- Test updates:
- Removed
apollo-upload-server
as there are no upload tests yet. - Removed
get-port
as not providing a port toapp.listen
has the same effect.
- Removed
- Example updates:
- Stop using
esm
due to graphql/express-graphql#425. - Enabled GraphiQL and added a link to it on the homepage.
- Stop using
- Updated the
react
peer dependency to^16.3.1
. - Fixed
preload
broken due to the React v16.3.1 context API change.
- Updated dependencies.
- Example updates:
- Valid length app manifest
short_name
. - Added
<html>
lang
attribute. - Added Twitter card meta tags.
- Valid length app manifest
- Added a
fetchError
Query
render function argument, enabling graceful caching and handling of errors in situations such as when a globalfetch
API is unavailable or a relative URL is used on the sever.
- Updated dependencies.
- Replaced
isomorphic-unfetch
with the more updatedcross-fetch
. - Use
.prettierignore
to deferpackage.json
formatting to npm. - Improved the example web app and deployed it to graphql-react.now.sh.
- Support the legacy React context API, fixing #7.
- Use
eslint-plugin-ava
.
- Removed the
Promise
polyfill; consumers can polyfill as required for optimal bundle size. Required polyfills are documented in the readme.
- Significantly reduced the bundle size to < 4 KB by simplifying Babel helpers and reusing the
object-assign
React dependency withbabel-plugin-transform-replace-object-assign
.
- Updated dependencies.
- Updated ESLint config:
parserOptions
is unnecessary when usingbabel-eslint
.- Enabled
prefer-destructuring
rule.
- Updated Node.js support to v7.6+.
- Renamed
GraphQLProvider
andGraphQLConsumer
toProvider
andConsumer
. - No longer exporting
GraphQLQuery
. - Swapped the
GraphQLQuery
andQuery
names. - Removed
GraphQLMutation
component;GraphQLQuery
can be used for both queries and mutations. GraphQLQuery
componentloadOnMount
andloadOnReset
props now default tofalse
:- Opt-in is safer for mutations.
- Removing
static defaultProps
reduces bundle size. - Nicer valueless boolean props (
<GraphQLQuery />
and<GraphQLQuery loadOnReset />
vs<GraphQLQuery loadOnReset={false} />
and<GraphQLQuery loadOnReset={true} />
.
- The
GraphQL
query
instance method now accepts an options object. - New approach to configuring GraphQL request fetch options:
- Removed the
GraphQL
constructorrequestOptions
option. - The
Query
component now has afetchOptionsOverride
prop, allowing components to easily query any GraphQL API. Consumers may export an override function tailored for each API in one place to make things DRY. - The Next.js example app has been updated to demo the new API using the external GraphQL Pokémon API.
- Removed the
- New
preload
API for server side rendering, fixing #2. - The
Query
componentresetOnLoad
prop doesn’t cause cache for the request that triggered a reset to delete, allowing simultaneous use withloadOnReset
. Fixes #3. - The
GraphQL
reset
instance method now accepts a fetch options hash to exempt a request from cache deletion.
- Updated dependencies.
- Fetch errors when a request could not be sent at all (e.g. a relative URL can’t be used for server side rendering) are uncaught instead of incorrectly cached as a
parseError
. - Simplified the JSDoc script, now that Documentation.js handles
.mjs
. - Prevent lib or example updates from triggering tests in watch mode.
- Fixed the example setup script and made
graphql-react
a published dependency, via #1. - Commented GraphQL template literals for editor syntax highlighting.
- Configured Travis and added a build status readme badge.
- Improved API documentation.
Initial release.