NlaakALDN
Convex Community10mo ago
5 replies
NlaakALD

api.somemodule.somefunction

I have several mature modules (ie, api.user., api.blogs., etc) and i try to break them up into smaller files but it breaks everything unless i rename everything.
  //const globalPresence = useQuery(api.users.getPresence);           // Does not work
  //const globalPresence = useQuery(api.users.index.getPresence);     // Does work
  const globalPresence = useQuery(api.users.queries.getPresence);     // Does work


// file: ./convex/users/index.ts
// feature: Chat - Main export file for users module

// Re-export everything to maintain the same API paths
export * from "./queries";
export * from "./mutations";
export * from "./helpers";
export * from "./types";


Shouldn't convex also support the index.ts principal?

I can update all the projects to call api functions differently, but it is kind of a pain in the butt when and index should do.

  //const globalPresence = useQuery(api.users.getPresence);               // Does not work
  //const globalPresence = useQuery(api.users.index.getPresence);         // Does work
  const globalPresence = useQuery(api.users.queries.getPresence);         // Does work
  
  const updateProfile = useMutation(api.users.updateProfile);             // Does not work
  //const updateProfile = useMutation(api.users.mutations.updateProfile); // Does work
  //const updateProfile = useMutation(api.users.index.updateProfile);     // Does work

or is there a way to do this i am missing in the documenation?
Was this page helpful?