A GraphQL client for React using modern context and hooks APIs that is lightweight (< 4 kB) but powerful; the first Relay and Apollo alternative with server side rendering.
MIT License
Bot releases are visible (Hide)
Published by jaydenseric over 5 years ago
response
property to the GraphQL
instance cache
event payload, containing the original fetch
Response
instance the cacheValue
was derived from.useGraphQL
options guide for common situations.GraphQL
instance method operate
with both reloadOnLoad
and resetOnLoad
options true
.FormData
field names, as some FormData
polyfills don't coerce numbers like native implementations do.Published by jaydenseric over 5 years ago
GraphQLProvider
component that prevents unnecessary loading on the client after SSR, fixing #4. This component should be used instead of using GraphQLContext.Provider
directly. The old way still works, but with the old behavior.GraphQLContext.Consumer
example to use React hooks.Published by jaydenseric over 5 years ago
size-limit
config file name.useGraphQL
render error when options reloadOnLoad
and resetOnLoad
are both true
.useGraphQL
to track mounted status for cache related callbacks.GraphQL
instance method operate
option reloadOnLoad
.Published by jaydenseric over 5 years ago
useGraphQL
to use useCallback
and added hook dependency arrays, to fix a recently appearing react-hooks/exhaustive-deps
lint error and hopefully reduce render work.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 in node_modules
.Published by jaydenseric over 5 years ago
useGraphQL
internal useEffect
React hook second arguments.useGraphQL
React hook is unmounted soon after an GraphQL
instance event such as reset
is emitted.Published by jaydenseric over 5 years ago
GraphQL
instance method reload
which fires a reload
event signaling that GraphQL cache subscribers such as the useGraphQL
React hook should reload their GraphQL operation, fixing #26.useGraphQL
React hook reloadOnLoad
option.useGraphQL
React hook loadOnMount
option implementation that fixes ESLint react-hooks/exhaustive-deps
rule errors.function
instead of const
declarations in places to simplify transpiled output.GraphQL.reset()
test name typo fix.useGraphQL
React hook reloadOnLoad
and resetOnLoad
options.GraphQL
instance event documentation.Published by jaydenseric over 5 years ago
useGraphQL
React hook bug fix for when arguments change after the initial render and the load
function is called: loading
and cacheValue
now update correctly after the operation loads.Published by jaydenseric over 5 years ago
useGraphQL
React hook bug fixes for when arguments change after the initial render:
cacheKey
to change trigger a reload if the loadOnMount
option is true
, fixing #23.react-test-renderer
to test useGraphQL
with a lot more detail.React
namespace in useGraphQL
.hashObject()
tests.Published by jaydenseric over 5 years ago
Updated the react
and react-dom
peer dependencies to ^16.8.0
.
Removed the Query
component.
No longer exporting Provider
and Consumer
; now GraphQLContext
is exported.
The GraphQL
instance method query
has been renamed operate
.
The GraphQL
constructor no longer has the logErrors
option, and GraphQL operation errors are no longer console logged by default.
The ssr
function is now exported from graphql-react/server
instead of graphql-react/lib/ssr
.
The ssr
function is now implemented using async
/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
options body
is a FormData
instance has been improved. Previously they would overwrite each other in the cache even if the GraphQL operations were different, depending if the FormData
instance was native or from a polyfill that could be JSON serialized.
There is still room to improve as FormData
field values that are File
or Blob
instances don’t influence the cache key hashing.
GraphQL
event properties have been renamed or added:
fetch
event property fetchOptionsHash
was renamed cacheKey
, and the property cache
was renamed cacheValuePromise
.cache
event property fetchOptionsHash
was renamed cacheKey
, and the property cacheValue
was added.reset
event property exceptFetchOptionsHash
was renamed exceptCacheKey
.useGraphQL
React hook, which assumes the role of the removed Query
component.GraphQL
on
and off
methods for managing event listeners.reportCacheErrors
function, a GraphQL
cache
event handler that can be setup to report GraphQL operation errors via console.log()
.prepublishOnly
script.tap
CLI and default reporter for tests.test
script as they are the slowest.Published by jaydenseric over 5 years ago
preload
function. It was not going to work with React hooks.react-dom
peer dependency.main
package entry).ssr
function, which is for server use only and is React hooks ready. It is simpler and more future-proof than the removed preload
function as it leverages ReactDOMServer
for rendering.GraphQL
now emits a cache
promise in the fetch
event payload. These events are undocumented, so this could be considered an internal change.ReactNode
JSDoc type, replacing ReactElement
types.preload
function.Published by jaydenseric almost 6 years ago
watch
dev dependency and watch
package script.preload
now properly catches render errors nested under Query
components.preload
now supports class components that don’t call their base constructor with props
, fixing #17.graphQLErrors
JSDoc type.Published by jaydenseric almost 6 years ago
preload
reject upon render errors instead of throwing.Query
component throw a helpful render error if the GraphQL context is missing.size-limit
tests:
prop-types
since it’s likely to already be present in a React project, and most frameworks strip it out in production bundles anyway.Published by jaydenseric almost 6 years ago
extract-files
dependency to v5:
.prettierignore
entry.graphqlFetchOptions
function.Published by jaydenseric almost 6 years ago
GraphQL
constructor option logErrors
(default true
) and instance property, controlling if GraphQL request errors should be console logged for easy debugging.GraphQL
static methods to separate modules.*
.Published by jaydenseric almost 6 years ago
> 1%
to > 0.5%, not dead
.browserslist
field due to a sneaky @babel/preset-env
breaking change.Published by jaydenseric almost 6 years ago
Published by jaydenseric almost 6 years ago
react
peer dependency to ^16.6.0
.preload
broken due to the React v16.6.0 context API change, fixing #11.Published by jaydenseric about 6 years ago
Query
(and the internal GraphQLQuery
) component take an operation
prop instead of separate variables
and query
props. This makes the implementation a little more elegant, is more consistent with the GraphQL.query
API and allows sending custom GraphQL operation fields.loading
parameter of Query
component render functions change when identical requests are loaded elsewhere in the app.Provider
and Consumer
component display names in React dev tools:
Context.Provider
→ GraphQLContext.Provider
Context.Consumer
→ GraphQLContext.Consumer
husky
version.module
field. Webpack by default 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 when module
points to an .mjs
ESM file and they attempt to resolve named imports from .js
CJS files.Operation
type GraphQLOperation
.Published by jaydenseric about 6 years ago
GraphQLQuery
component from API documentation as it used internally and is not exported.jsdoc-md
version.Published by jaydenseric about 6 years ago
prepare
script to support installation via Git (e.g. npm install jaydenseric/graphql-react
).@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.rimraf
dev dependency in favour of a native rm -rf
package clean script. Leaner and faster; we only support *nix for contributing anyway.fake-tag
dev dependency now that Prettier can format template literals tagged with /* GraphQL */
.npm-run-all
for package scripts to reduce complexity and bugs.repository
field..yml
files.graphql-api-koa
instead of express-graphql
.jsdoc-md
instead of documentation
to generate readme API docs.master
branch.package.json
and rarely changes.