Skip to content

Commit

Permalink
update version to pull additional descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
TristenHarr committed Dec 6, 2024
1 parent 455f4ec commit 5bdfa30
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This changelog documents the changes between release versions.
## [Unreleased]
Changes to be included in the next upcoming release

## [0.1.4] - 2024-12-05
* Update the Python SDK
* Add annotations to fields from pydantic models

## [0.1.3] - 2024-12-05
* Update the Python SDK
* Fix nullable responses
Expand Down
13 changes: 12 additions & 1 deletion connector-definition/template/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
from hasura_ndc.instrumentation import with_active_span # If you aren't planning on adding additional tracing spans, you don't need this!
from opentelemetry.trace import get_tracer # If you aren't planning on adding additional tracing spans, you don't need this either!
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
from pydantic import BaseModel, Field # 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
from typing import Annotated

connector = FunctionConnector()

Expand Down Expand Up @@ -106,5 +107,15 @@ async def parallel_query(name: str) -> str:
def error():
raise UnprocessableContent(message="This is a error", details={"Error": "This is a error!"})

class Foo(BaseModel):
bar: str = Field(..., description="The bar field") # Add a field description
baz: Annotated[str, "The baz field"] # A different way to add a field description

# You can use Field or Annotated to add descriptions to the metadata
@connector.register_query
def annotations(foo: Foo | None = Field(..., description="The optional input Foo")) -> Foo | None:
"""Writing a doc-string like this will become the function/procedure description"""
return None

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.36
hasura-ndc==0.37
idna==3.7
importlib-metadata==7.0.0
opentelemetry-api==1.24.0
Expand Down

0 comments on commit 5bdfa30

Please sign in to comment.