Lucas
TTCTheo's Typesafe Cult
•Created by Lucas on 10/19/2023 in #questions
Upgrading to App Dir with create-t3
I'm running into the error:
Everything seems to be imported correctly and I am not sure what the issue is. Does anyone have any ideas?
<< query #1 company.getAllForAdmin {
input: { orderBy: 'name', orderDirection: 'asc' },
result: TRPCClientError: No "query"-procedure on path "company.getAllForAdmin"
at TRPCClientError.from (webpack-internal:///(rsc)/../../node_modules/@trpc/client/dist/TRPCClientError-0de4d231.mjs:30:20)
at eval (webpack-internal:///(rsc)/../../node_modules/@trpc/client/dist/links/httpLink.mjs:42:105)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
meta: { response: [_Response [Response]], responseJSON: [Object] },
shape: {
message: 'No "query"-procedure on path "company.getAllForAdmin"',
code: -32004,
data: [Object]
},
data: {
code: 'NOT_FOUND',
httpStatus: 404,
stack: 'TRPCError: No "query"-procedure on path "company.getAllForAdmin"\n' +
' at callProcedure (webpack-internal:///(rsc)/../../node_modules/@trpc/server/dist/config-4c0f8e88.mjs:183:15)\n' +
' at inputToProcedureCall (webpack-internal:///(rsc)/../../node_modules/@trpc/server/dist/resolveHTTPResponse-68c8befb.mjs:54:83)\n' +
' at eval (webpack-internal:///(rsc)/../../node_modules/@trpc/server/dist/resolveHTTPResponse-68c8befb.mjs:177:51)\n' +
' at Array.map (<anonymous>)\n' +
' at resolveHTTPResponse (webpack-internal:///(rsc)/../../node_modules/@trpc/server/dist/resolveHTTPResponse-68c8befb.mjs:177:32)',
path: 'company.getAllForAdmin',
zodError: null
},
[cause]: undefined
},
elapsedMs: 415
}
<< query #1 company.getAllForAdmin {
input: { orderBy: 'name', orderDirection: 'asc' },
result: TRPCClientError: No "query"-procedure on path "company.getAllForAdmin"
at TRPCClientError.from (webpack-internal:///(rsc)/../../node_modules/@trpc/client/dist/TRPCClientError-0de4d231.mjs:30:20)
at eval (webpack-internal:///(rsc)/../../node_modules/@trpc/client/dist/links/httpLink.mjs:42:105)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
meta: { response: [_Response [Response]], responseJSON: [Object] },
shape: {
message: 'No "query"-procedure on path "company.getAllForAdmin"',
code: -32004,
data: [Object]
},
data: {
code: 'NOT_FOUND',
httpStatus: 404,
stack: 'TRPCError: No "query"-procedure on path "company.getAllForAdmin"\n' +
' at callProcedure (webpack-internal:///(rsc)/../../node_modules/@trpc/server/dist/config-4c0f8e88.mjs:183:15)\n' +
' at inputToProcedureCall (webpack-internal:///(rsc)/../../node_modules/@trpc/server/dist/resolveHTTPResponse-68c8befb.mjs:54:83)\n' +
' at eval (webpack-internal:///(rsc)/../../node_modules/@trpc/server/dist/resolveHTTPResponse-68c8befb.mjs:177:51)\n' +
' at Array.map (<anonymous>)\n' +
' at resolveHTTPResponse (webpack-internal:///(rsc)/../../node_modules/@trpc/server/dist/resolveHTTPResponse-68c8befb.mjs:177:32)',
path: 'company.getAllForAdmin',
zodError: null
},
[cause]: undefined
},
elapsedMs: 415
}
5 replies
TTCTheo's Typesafe Cult
•Created by Lucas on 10/19/2023 in #questions
Upgrading to App Dir with create-t3
router procedure:
getAllForAdmin: publicProcedure
.input(
z.object({
orderBy: z.enum(["id", "name", "city", "country"]),
orderDirection: z.enum(["asc", "desc"]),
searchQuery: z.string().optional(),
productUuid: z.string().optional(),
})
)
.query(async ({ ctx, input }) => {
console.log("get all for admin was hit successfully")
const { orderBy, orderDirection, searchQuery, productUuid } = input;
const sanitizedsearchQuery = searchQuery?.replace(/[^\w\s]/gi, " ");
const where: Prisma.CompanyWhereInput = {
name: {
contains: sanitizedsearchQuery,
},
};
// redacted
const companies = await prisma.company.findMany({
// redacted
});
if (!companies) {
throw new TRPCError({
code: "NOT_FOUND",
message: "No companies found.",
});
}
// add element idString to each company, which is id.toString(). map it to new object
const companiesWithIdString = companies.map((company) => {
return {
...company,
idString: company.id.toString(),
};
});
return companiesWithIdString;
}),
getAllForAdmin: publicProcedure
.input(
z.object({
orderBy: z.enum(["id", "name", "city", "country"]),
orderDirection: z.enum(["asc", "desc"]),
searchQuery: z.string().optional(),
productUuid: z.string().optional(),
})
)
.query(async ({ ctx, input }) => {
console.log("get all for admin was hit successfully")
const { orderBy, orderDirection, searchQuery, productUuid } = input;
const sanitizedsearchQuery = searchQuery?.replace(/[^\w\s]/gi, " ");
const where: Prisma.CompanyWhereInput = {
name: {
contains: sanitizedsearchQuery,
},
};
// redacted
const companies = await prisma.company.findMany({
// redacted
});
if (!companies) {
throw new TRPCError({
code: "NOT_FOUND",
message: "No companies found.",
});
}
// add element idString to each company, which is id.toString(). map it to new object
const companiesWithIdString = companies.map((company) => {
return {
...company,
idString: company.id.toString(),
};
});
return companiesWithIdString;
}),
5 replies