Error Handling
There are 2 ways you can handle errors in GraphQL: you can either have documents throw an exception if an
error key is located in the payload (and is a list with at least one member) or they can fail silently
and rely on application level code to function.
By default, Houdini will behave “silently” and not throw any exceptions if an error is the query response is
seen. If you want to turn on exceptions, you can specify the details in the throwOnError field:
import { error } from '@sveltejs/kit'
export default new HoudiniClient({ url: '...', throwOnError: { // can be any combination of // query, mutation, subscription, and all operations: ['all'], // the function to call error: (errors, ctx) => error(500, `(${ctx.artifact.name}): ` + errors.map((err) => err.message).join('. ') + '.' ) }})import { error } from '@sveltejs/kit'
export default new HoudiniClient({ url: '...', throwOnError: { // can be any combination of // query, mutation, subscription, and all operations: ['all'], // the function to call error: (errors, ctx) => error(500, `(${ctx.artifact.name}): ` + errors.map((err) => err.message).join('. ') + '.') }})