Skip to content

Commit

Permalink
update to add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
TristenHarr committed Aug 8, 2024
1 parent 1a8f46a commit 465ba62
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ This changelog documents the changes between release versions.
## [Unreleased]
Changes to be included in the next upcoming release

## [0.0.38] - 2024-08-08
* Add errors and error handling to SDK

## [0.0.37] - 2024-08-07
* Fix schema endpoint to be aware of parallel execution

Expand Down
7 changes: 7 additions & 0 deletions connector-definition/template/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from hasura_ndc.function_connector import FunctionConnector
from pydantic import BaseModel # You only need this import if you plan to have complex inputs/outputs, which function similar to how frameworks like FastAPI do
import asyncio # You might not need this import if you aren't doing asynchronous work
from hasura_ndc.errors import UnprocessableContent

connector = FunctionConnector()

Expand Down Expand Up @@ -99,5 +100,11 @@ async def parallel_query(name: str) -> str:
await asyncio.sleep(1)
return f"Hello {name}"

# This is an example of how you can throw an error
# There are different error types including: BadRequest, Forbidden, Conflict, UnprocessableContent, InternalServerError, NotSupported, and BadGateway
@connector.register_query
def error():
raise UnprocessableContent(message="This is a error", details={"Error": "This is a error!"})

if __name__ == "__main__":
start(connector)
2 changes: 1 addition & 1 deletion connector-definition/template/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fastapi==0.110.2
googleapis-common-protos==1.63.0
grpcio==1.62.2
h11==0.14.0
hasura-ndc==0.23
hasura-ndc==0.24
idna==3.7
importlib-metadata==7.0.0
opentelemetry-api==1.24.0
Expand Down

0 comments on commit 465ba62

Please sign in to comment.