-
ProblemCurrently the generated API routes are based on the filepath of the query/mutation resolvers. Example: This means you can't re-organize your file structure without changing the generated API routes. This is very bad for mobile apps because mobile apps always have legacy versions in use. For mobile apps, you want to make zero breaking changes to your API if possible. Solution
Alternate 1
Other ConsiderationsVersioningThe main other consideration for mobile apps is versioning. What if you want to make a breaking change to a query/mutation? One idea I have is to allow rpc path nesting like this:
That can be implemented a bit later, but we should consider it in this breaking change for api paths. Backward compatibility for apps depending on current pathsWe should be able to use rewrites and concoct a regex that makes the old generated paths re-map to the new paths. So what are your thoughts on this? Anything I'm overlooking? Any clever ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
What if, inside the file of each mutation or query, you could export a constant with the path you want? Without the api prefix because it's added automatically. This will let devs customize the URL or change it if they are sure, you could also add a version yourself in case you want to support more than one version. |
Beta Was this translation helpful? Give feedback.
-
Any reason to not make the api root path configurable? Like if you're making a URL shortener or something you might want to change it in blitz.config.js - apiRootPath: "/api/rpc"
+ apiRootPath: "/s" |
Beta Was this translation helpful? Give feedback.
-
I think this would be a beneficial change. In blitz, there are really three namespaces: API routes, RPC routes, and react pages. Currently, react pages are at |
Beta Was this translation helpful? Give feedback.
-
One of the best features of blitz is the 'Loose Opinions' part. To keep that promise I believe it's best to leave developers to freely build their apis however they want and offer a plug-in-like proxy solution where they can redirect the obsolete routes, giving as many time as needed for the migration to happen. something like: // .proxy.js
export const config = {
redirects: ['/api/createUser', '/api/newCreateUser']
} you can redirect pages too if you want. all done server side |
Beta Was this translation helpful? Give feedback.
-
This change is now available in https://github.com/blitz-js/blitz/releases/tag/v0.40.0-canary.0! |
Beta Was this translation helpful? Give feedback.
This change is now available in https://github.com/blitz-js/blitz/releases/tag/v0.40.0-canary.0!