You can configure certain RPC aspects within your next.config.js file
inside the blitz property.
To change how every file path is resolved, you can set the resolverPath
option inside next.config.js.
module.exports = withBlitz({
blitz: {
resolverPath: "queries|mutations",
},
})
// Or with a custom function
module.exports = withBlitz({
blitz: {
resolverPath: (filePath) => {
return filePath.replace("app/", "") // Removes `app/` from the path
},
},
})There are three options to determine how the RPC path is resolved during build.
queries|mutations (default)queries or mutations folder as the rootrootExample output:
File: src/products/queries/getProduct.ts
"queries|mutations" URL: /api/rpc/getProduct
"root" URL: src/products/queries/getProduct
File: src/products/mutations/createProduct.ts
"queries|mutations" URL: /api/rpc/createProduct
"root" URL: src/products/mutations/createProduct
File: src/products/mutations/v2/createProduct.ts
"queries|mutations" URL: /api/rpc/v2/createProduct
"root" URL: src/products/mutations/v2/createProductInside the blitz property add the param includeRPCFolders as an array
of relative path folders from your Blitz root folder. For example:
module.exports = withBlitz({
blitz: {
includeRPCFolders: ["../../<YOUR DIRECTORY PATH>"],
},
}) Your resolvers still need to be placed in queries or mutations
folders.