naystack - v1.5.10
    Preparing search index...

    Function GQLError

    • 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:

      • 400 → "Please provide all required inputs"
      • 403 → "You are not allowed to perform this action"
      • 404 → "Entity not found"
      • other → "Server Error"

      Parameters

      • Optionalstatus: number

        HTTP-like status code (e.g. 400, 403, 404). Defaults to 500.

      • Optionalmessage: string

        Override the default message for the status. If omitted, the default above is used.

      Returns GraphQLError

      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");