pub struct GraphQLError {
pub message: String,
pub code: ErrorCode,
pub locations: Option<Vec<ErrorLocation>>,
pub path: Option<Vec<String>>,
pub extensions: Option<ErrorExtensions>,
}Expand description
GraphQL error following spec.
Fields§
§message: StringError message.
code: ErrorCodeError code for client handling.
locations: Option<Vec<ErrorLocation>>Location in query where error occurred.
path: Option<Vec<String>>Path to field that caused error.
extensions: Option<ErrorExtensions>Additional error information.
Implementations§
Source§impl GraphQLError
impl GraphQLError
Sourcepub fn with_location(self, line: usize, column: usize) -> Self
pub fn with_location(self, line: usize, column: usize) -> Self
Add location to error.
Sourcepub fn with_extensions(self, extensions: ErrorExtensions) -> Self
pub fn with_extensions(self, extensions: ErrorExtensions) -> Self
Add extensions to error.
Sourcepub fn with_request_id(self, request_id: impl Into<String>) -> Self
pub fn with_request_id(self, request_id: impl Into<String>) -> Self
Add request ID for distributed tracing.
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Validation error.
Sourcepub fn parse(message: impl Into<String>) -> Self
pub fn parse(message: impl Into<String>) -> Self
Parse error with hint for common syntax issues.
Sourcepub fn database(message: impl Into<String>) -> Self
pub fn database(message: impl Into<String>) -> Self
Database error - includes connection, timeout, and query errors.
Sourcepub fn internal(message: impl Into<String>) -> Self
pub fn internal(message: impl Into<String>) -> Self
Internal server error - unexpected conditions.
Sourcepub fn unauthenticated() -> Self
pub fn unauthenticated() -> Self
Unauthenticated error - authentication token is missing or invalid.
Sourcepub fn not_found(message: impl Into<String>) -> Self
pub fn not_found(message: impl Into<String>) -> Self
Not found error - requested resource does not exist.
Sourcepub fn timeout(operation: impl Into<String>) -> Self
pub fn timeout(operation: impl Into<String>) -> Self
Timeout error - operation took too long and was cancelled.
Sourcepub fn rate_limited(message: impl Into<String>) -> Self
pub fn rate_limited(message: impl Into<String>) -> Self
Rate limit error - too many requests from client.
Sourcepub fn from_fraiseql_error(err: &FraiseQLError) -> Self
pub fn from_fraiseql_error(err: &FraiseQLError) -> Self
Construct a typed GraphQLError from a fraiseql_core::error::FraiseQLError executor
error.
Maps specific core error variants to their closest HTTP-semantic equivalent, preserving type information for correct client handling and sanitizer routing.
Sourcepub fn persisted_query_not_found() -> Self
pub fn persisted_query_not_found() -> Self
Persisted query not found — client must re-send the full query body.
Sourcepub fn persisted_query_mismatch() -> Self
pub fn persisted_query_mismatch() -> Self
Persisted query hash mismatch — SHA-256 of body does not match the provided hash.
Sourcepub fn forbidden_query() -> Self
pub fn forbidden_query() -> Self
Raw query forbidden — trusted documents strict mode requires a documentId.
Sourcepub fn document_not_found(doc_id: impl Into<String>) -> Self
pub fn document_not_found(doc_id: impl Into<String>) -> Self
Document not found — the provided documentId is not in the trusted manifest.
Sourcepub fn circuit_breaker_open(entity: &str, retry_after_secs: u64) -> Self
pub fn circuit_breaker_open(entity: &str, retry_after_secs: u64) -> Self
Circuit breaker open — federation entity temporarily unavailable.
The response will carry a Retry-After header set to retry_after_secs.
Trait Implementations§
Source§impl Clone for GraphQLError
impl Clone for GraphQLError
Source§fn clone(&self) -> GraphQLError
fn clone(&self) -> GraphQLError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GraphQLError
impl Debug for GraphQLError
Source§impl From<GraphQLError> for ErrorResponse
impl From<GraphQLError> for ErrorResponse
Source§fn from(error: GraphQLError) -> Self
fn from(error: GraphQLError) -> Self
Auto Trait Implementations§
impl Freeze for GraphQLError
impl RefUnwindSafe for GraphQLError
impl Send for GraphQLError
impl Sync for GraphQLError
impl Unpin for GraphQLError
impl UnsafeUnpin for GraphQLError
impl UnwindSafe for GraphQLError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more