api layer v0.2.5 - graphql standardization

This commit is contained in:
jokob-sk
2025-08-21 15:33:32 +10:00
parent cbf2cd0ee8
commit 73fd094cfc
3 changed files with 30 additions and 10 deletions

View File

@@ -64,8 +64,15 @@ def graphql_endpoint():
# Execute the GraphQL query
result = devicesSchema.execute(data.get("query"), variables=data.get("variables"))
# Return the result as JSON
return jsonify(result.data)
# Initialize response
response = {}
if result.errors:
response["errors"] = [str(e) for e in result.errors]
if result.data:
response["data"] = result.data
return jsonify(response)
# --------------------------
# Device Endpoints