As an API consumer, I want to receive clear and instructional error messages so that I can understand what went wrong and how to fix it when either sending requests to REST or GraphQL endpoints.
Acceptance Criteria
[ ] The API should validate input data and provide descriptive error messages when data does not meet the required schema.
[ ] The API should return HTTP status codes that align with the nature of the error for REST endpoints (400 for client errors, 500 for server errors, etc.).
[ ] The API should return standardized error objects in the response body, conforming to a consistent structure for both REST and GraphQL.
[ ] For GraphQL, errors should also include the location of the error in the query when applicable.
[ ] Errors in GraphQL should contain extensions with error codes and a trace ID for better client-side error handling.
[ ] The API should implement rate limiting and return appropriate error messages when the limit is exceeded.
[ ] The API should handle exceptions gracefully and return errors in a structured format rather than exposing stack traces or sensitive server information.
sequenceDiagram
participant Client as API Consumer
participant Server as API Server
Client->>Server: Send request with invalid data
Note over Server: Validation Logic
alt is REST
Server->>Client: HTTP 400 Bad Request with error message in body
else is GraphQL
Server->>Client: GraphQL Error with message, locations, extensions
end
Error Handling and Validation for API Endpoints
As an API consumer, I want to receive clear and instructional error messages so that I can understand what went wrong and how to fix it when either sending requests to REST or GraphQL endpoints.
Acceptance Criteria