Creates a GraphQL error with an HTTP status code in extensions.statusCode. Use in resolvers when validation, authorization, or lookup fails.
extensions.statusCode
Default messages by status:
Optional
HTTP-like status code (e.g. 400, 403, 404). Defaults to 500.
Override the default message for the status. If omitted, the default above is used.
GraphQLError with extensions.statusCode set.
import { GQLError } from "naystack/graphql";// In a resolver:if (!input.email) throw GQLError(400);if (!ctx.userId) throw GQLError(403);if (!deal) throw GQLError(404, "Deal not found"); Copy
import { GQLError } from "naystack/graphql";// In a resolver:if (!input.email) throw GQLError(400);if (!ctx.userId) throw GQLError(403);if (!deal) throw GQLError(404, "Deal not found");
Creates a GraphQL error with an HTTP status code in
extensions.statusCode. Use in resolvers when validation, authorization, or lookup fails.Default messages by status: