Delveroff
Delveroff4mo ago

helping Delveroff

Hi! Could somebody help me? I need to call internal queries/mutations remotely. I use Next.js and SSR. I would like to fetchQuery(internal.tasks.list). But it doesn't work. I want to make queries internal so I don't validate the input parameters (I want to do it elsewhere). Supabase, i.e., provides us with two keys: default and anon. Anon is for public API. Default is for private use.
15 Replies
Jamal
Jamal4mo ago
Are you using fetchQuery from convex/nextjs?
Module: nextjs | Convex Developer Hub
Helpers for integrating Convex into Next.js applications using server rendering.
Jamal
Jamal4mo ago
I need to call internal queries/mutations remotely.
The only way to do this currently is using http actions https://docs.convex.dev/functions/http-actions. Then you can call convex functions from external API's
Delveroff
DelveroffOP4mo ago
Yeah, it gives the following error
No description
Jamal
Jamal4mo ago
Could you show a little code if you dont mind i would like to see how your using this function so i can debug the error better
Delveroff
DelveroffOP4mo ago
Sure
No description
Delveroff
DelveroffOP4mo ago
I don't have something more verbose since I'm just playing with Convex import { fetchQuery } from 'convex/nextjs'
Jamal
Jamal4mo ago
So your defining a function test. 1. The internal function is missing the args object.
export const test = internalQuery({
args: { test: v.string() },
handler: async (ctx, args) => {
// your code
},
});
export const test = internalQuery({
args: { test: v.string() },
handler: async (ctx, args) => {
// your code
},
});
lee
lee4mo ago
i would recommend making these public queries and using a shared secret to authenticate search discord for "shared secret" to find examples
Jamal
Jamal4mo ago
2. fetchQuery is meant to be used in your nextjs react component not in your convex/ function directory
Delveroff
DelveroffOP4mo ago
Yeah, I know, this is for example simplicity It doesn't matter since the error is about 'internal' and 'public' mismatch on TypeScript level
Jamal
Jamal4mo ago
internal functions can only be called by public convex functions, thats why this is not working
Delveroff
DelveroffOP4mo ago
I was thinking exactly about this. Thank you for a "shared secret" hint, will search Discord with it.
Delveroff
DelveroffOP4mo ago
Great! It will do, thank you!

Did you find this page helpful?