whoami
whoami2y ago

Usage in Python client

Is there any detailed example/demo on python client? How do I pass Id<Chat> in python client? This is my function definition under convex/ask.ts
export const insert = mutationz(
{
chat: zconvex.id('chat'),
content: z.string().nonempty().max(256),
},
...
export const insert = mutationz(
{
chat: zconvex.id('chat'),
content: z.string().nonempty().max(256),
},
...
and I was trying to call it in Python via
convex_client.mutation('ask:insert', {'chat': {'tableName': 'chat', 'id': '...'}, 'content': '...'})
convex_client.mutation('ask:insert', {'chat': {'tableName': 'chat', 'id': '...'}, 'content': '...'})
but got no luck
Uncaught ZodError: [
{
"code": "invalid_arguments",
"argumentsError": {
"issues": [
{
"code": "custom",
"fatal": true,
"path": [
0,
"chat"
],
"message": "Invalid input"
}
],
"name": "ZodError"
},
"path": [],
"message": "Invalid function arguments"
}
]
Uncaught ZodError: [
{
"code": "invalid_arguments",
"argumentsError": {
"issues": [
{
"code": "custom",
"fatal": true,
"path": [
0,
"chat"
],
"message": "Invalid input"
}
],
"name": "ZodError"
},
"path": [],
"message": "Invalid function arguments"
}
]
2 Replies
ballingt
ballingt2y ago
Ah, you want to use a convex.Id instead of a dictionary with two fields from convex import Id Typically you don't need to construct one though, you can just an id object received in a query
convex_client.mutation('ask:insert', dict(chat=message._id, content="content here"))
convex_client.mutation('ask:insert', dict(chat=message._id, content="content here"))
whoami
whoamiOP2y ago
oh cool checking it out now

Did you find this page helpful?