Delveroff
Delveroff3w 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
CodingWithJamal
Are you using fetchQuery from convex/nextjs?
Module: nextjs | Convex Developer Hub
Helpers for integrating Convex into Next.js applications using server rendering.
CodingWithJamal
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
DelveroffOP3w ago
Yeah, it gives the following error
No description
CodingWithJamal
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
DelveroffOP3w ago
Sure
No description
Delveroff
DelveroffOP3w ago
I don't have something more verbose since I'm just playing with Convex import { fetchQuery } from 'convex/nextjs'
CodingWithJamal
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
lee3w ago
i would recommend making these public queries and using a shared secret to authenticate search discord for "shared secret" to find examples
CodingWithJamal
2. fetchQuery is meant to be used in your nextjs react component not in your convex/ function directory
Delveroff
DelveroffOP3w 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
CodingWithJamal
internal functions can only be called by public convex functions, thats why this is not working
Delveroff
DelveroffOP3w ago
I was thinking exactly about this. Thank you for a "shared secret" hint, will search Discord with it.
Delveroff
DelveroffOP3w ago
Great! It will do, thank you!

Did you find this page helpful?