{"id":47955,"library":"graphql-toe","title":"GraphQL TOE (Throw On Error)","description":"A <512 byte zero-dependency library that transforms GraphQL responses by replacing errored fields with throwing getters. Version 1.0.0 stable. It solves the ambiguous `null` problem in GraphQL by throwing when you access a field that errored, allowing natural error handling with try/catch or React ErrorBoundary. Works with any GraphQL client (Apollo, URQL, fetch) that returns `{ data, errors }` — unlike Relay which has native directives. Ships TypeScript types, supports ESM and CJS.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https+git://github.com/graphile/graphql-toe","tags":["javascript","graphql","throw","error","errors","raise","exception","semantic","null","typescript"],"install":[{"cmd":"npm install graphql-toe","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-toe","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-toe","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v1.0.0. CJS require() will fail.","wrong":"const toe = require('graphql-toe')","symbol":"toe","correct":"import { toe } from 'graphql-toe'"},{"note":"Named export only; there is no default export.","wrong":"import toe from 'graphql-toe'","symbol":"toe","correct":"import { toe } from 'graphql-toe'"},{"note":"GraphQLError is not exported from graphql-toe; use the `graphql` package if needed.","wrong":"import { GraphQLError } from 'graphql-toe'","symbol":"GraphQLError","correct":"import { GraphQLError } from 'graphql'"}],"quickstart":{"code":"import { toe } from 'graphql-toe';\n\nasync function fetchUsers() {\n  const response = await fetch('/graphql', {\n    method: 'POST',\n    headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({ query: '{ users { id name } }' })\n  });\n  const result = await response.json();\n  const data = toe(result);\n  try {\n    console.log(data.users[0].name);\n    console.log(data.users[1].name); // might throw\n  } catch (e) {\n    console.error('GraphQL error:', e.message);\n  }\n}","lang":"typescript","description":"Shows how to use toe() to transform a GraphQL response and handle errors via try/catch."},"warnings":[{"fix":"Always ensure the GraphQL response has a data field. Use try/catch around toe() to handle missing data.","message":"toe() requires result.data and result.errors arrays. If result.data is null, it throws immediately.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"For ambiguous nulls, verify that errors array contains a matching path. Consider preprocessing errors if needed.","message":"toe() only replaces null values that are due to errors. If a null exists in the data without an error entry, it will remain null (data-null).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Wrap the error object in an Error or GraphQLError before calling toe(), or add your own error handling.","message":"The thrown error is the raw error object from the errors array, not an Error instance. It may lack a stack trace.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"N/A","message":"No deprecated features in v1.0.0.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"If you need to preserve the original response, deep-clone before calling toe().","message":"toe() is not a deep clone; it modifies the original data object by replacing errored properties with throwing getters.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.0':25 '512':7 'access':39 'allow':44 'ambigu':30 'apollo':58 'byte':8 'cjs':77 'client':57 'data':63 'depend':11 'direct':70 'error':5,19,43,46,64,81,82 'errorboundari':52 'esm':75 'except':84 'fetch':60 'field':20,41 'getter':23 'graphql':1,15,34,56,79 'handl':47 'javascript':78 'librari':12 'nativ':69 'natur':45 'null':31,86 'problem':32 'rais':83 'react':51 'relay':66 'replac':18 'respons':16 'return':62 'semant':85 'ship':71 'solv':28 'stabl':26 'support':74 'throw':3,22,36,80 'toe':2 'transform':14 'try/catch':49 'type':73 'typescript':72,87 'unlik':65 'urql':59 'version':24 'work':53 'zero':10 'zero-depend':9","created_at":"2026-06-07T16:54:11.354638+00:00","updated_at":"2026-06-07T16:54:11.354638+00:00","problems":[{"fix":"Run 'npm install graphql-toe' and ensure import is 'graphql-toe' not 'graphql-toe/dist' or similar.","cause":"Package not installed or import path incorrect.","error":"Cannot find module 'graphql-toe'"},{"fix":"Change 'import toe from \"graphql-toe\"' to 'import { toe } from \"graphql-toe\"'.","cause":"Using default import instead of named import.","error":"TypeError: (0 , graphql_toe.toe) is not a function"},{"fix":"Use ESM import syntax: 'import { toe } from \"graphql-toe\"'.","cause":"Using CJS require() incorrectly.","error":"toe is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/graphile/graphql-toe","github":"https+git://github.com/graphile/graphql-toe","docs":null,"changelog":null,"pypi":null,"npm":"graphql-toe","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}