Skip to content

About

Have Errors Elevate Locally - client-side implementation of GraphQL error propagation to enable `onError: "NULL"` to be used with legacy applications.

Resources

Code of conduct

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

GraphQL-HEEL - Have Errors Elevate Locally

With the new onError: "NULL" GraphQL request property, there is no error propagation (null bubbling) on the server side. This is great for our client's normalized stores since it's now save to store results even if errors occurred, however existing applications may be expecting the traditional error propagation behavior.

This library has errors elevate locally, i.e. it implements the error propagation (null bubbling) behavior on the client side - thus a client using onError: "NULL" with the server can expose { data, errors } to the consuming application as if error propagation was enabled:

Example

import { heel } from "graphql-heel";

const res = await fetch("/graphql", {
  method: "POST",
  headers: {
    "content-type": "application/json",
    accept: "application/graphql-response+json",
  },
  body: JSON.stringify({
    query: `{ __typename }`,
  }),
});
const graphqlResponse = await res.json();

const { data, errors } = heel(graphqlResponse);

Alternatives

GraphQL HEEL helps clients adopt onError: "NULL" whilst supporting legacy applications - it's a rearward-facing approach (hence it's the heel). For a more forward-looking approach, see GraphQL TOE, where the application needs only deal with data (no errors list); errors are thrown when the failed field is read, and conventional error handling (try/catch and <ErrorBoundary />) is used to implement error boundaries

About

Have Errors Elevate Locally - client-side implementation of GraphQL error propagation to enable `onError: "NULL"` to be used with legacy applications.

Resources

Code of conduct

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages