Aps
Aps
CCConvex Community
Created by Aps on 5/19/2024 in #support-community
How to test development httpActions
Yep, thanks mate. Not sure why I thought it was the project name... All good now:)
3 replies
CCConvex Community
Created by Aps on 11/5/2023 in #support-community
Logs seem to have bugged?
Yes it is, thank you:)
3 replies
CCConvex Community
Created by Aps on 11/5/2023 in #support-community
Is there a limit on records in a DB table?
Thank you. Does the paid plan have no limitations in the number of documents you can have?
7 replies
CCConvex Community
Created by CodingWithJamal on 10/27/2023 in #support-community
React Server Components + Convex Auth State Support?
Since NextJS has its own backend, you would need to send this header manually and everything should work
9 replies
CCConvex Community
Created by CodingWithJamal on 10/27/2023 in #support-community
React Server Components + Convex Auth State Support?
From a convex function you can access the user identity as such:
import { mutation } from "./_generated/server";

export const myMutation = mutation({
args: {
// ...
},
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity();
const { tokenIdentifier, name, email } = identity!;
//...
},
});
import { mutation } from "./_generated/server";

export const myMutation = mutation({
args: {
// ...
},
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity();
const { tokenIdentifier, name, email } = identity!;
//...
},
});
Convex expects to find the jwt token in the Authorization header:
const jwtToken = "...";

fetch("https://<deployment name>.convex.site/myAction", {
headers: {
Authorization: `Bearer ${jwtToken}`,
},
});
const jwtToken = "...";

fetch("https://<deployment name>.convex.site/myAction", {
headers: {
Authorization: `Bearer ${jwtToken}`,
},
});
9 replies
CCConvex Community
Created by winsoroaks on 10/23/2023 in #support-community
configure ConvexReactClient to skip queries when input is undefined by default?
I mean if you use directly ctx.auth.getUserIdentity() in your client side, you will not receive an event when identify is changed.
12 replies
CCConvex Community
Created by winsoroaks on 10/23/2023 in #support-community
configure ConvexReactClient to skip queries when input is undefined by default?
The only problem with this in hooks is that it's not reactive, so your component would not re-render when the authentication state changes.
12 replies
CCConvex Community
Created by winsoroaks on 10/23/2023 in #support-community
configure ConvexReactClient to skip queries when input is undefined by default?
You could move authentication at a higher level in your app, so no other query is mounted until you are done with user authentication. If that's not possible you could use a helper hook like this:
function useIfAuthed<T>(params: T) {
const { isLoaded } = useAuth();
return isLoaded ? params : "skip";
}

function MyReactComponent() {
const customer = useQuery(
api.customerFuncs.getCustomer,
useIfAuthed({ id: customerId, })
)

// Do something with customer
}
function useIfAuthed<T>(params: T) {
const { isLoaded } = useAuth();
return isLoaded ? params : "skip";
}

function MyReactComponent() {
const customer = useQuery(
api.customerFuncs.getCustomer,
useIfAuthed({ id: customerId, })
)

// Do something with customer
}
12 replies
CCConvex Community
Created by Aps on 10/22/2023 in #support-community
Date is not a supported Convex type
In a custom serialisation we would be required to implement both a toJSON and a fromJSON function :) In any case, I don't think with a standard ISO 8601 date format as your default serialiser you would have any issues, as it's universally used and supported by the javascript Date class. You can either treat all dates as UTC (2022-12-31T00:00:00.000Z) or include the offset in the string (2022-12-31T00:00:00.000Z+00:00), although the former is more common.
9 replies
CCConvex Community
Created by Aps on 10/22/2023 in #support-community
Date is not a supported Convex type
Thanks! Unless there's a very specific reason I'm unaware of to do things differently, I would suggest to use the default javascript JSON.serialize method when returning data from a function. I understand that supporting custom serializers might be more work. Also 1 more question that rose from your response. You said that actions support returning JSON? How do I return JSON? Do I just return a string?
9 replies
CCConvex Community
Created by Aps on 10/22/2023 in #support-community
Date is not a supported Convex type
Thank you for your response and advice, I will follow it when it comes to DB data. My specific problem was returning values from an action. Which from my understanding is json stringifying the result and sending it in the json body of the response. If you're using some custom serializer, is there any way to extend it so date objects are serialized correctly (using standard ISO date format)? Or I need to create my own serializer and use in each action/query/mutation?
9 replies