I have a DELETE endpoint that needs an optional access query param:
// Validator
export const exampleDeleteValidatorV1 = vine.compile(
vine.object({
params: vine.object({...}),
access: vine.string().trim().optional(),
})
)
On the client side, I want to pass access as a query param:
$tuyau.request('example.delete', {
params: {...},
query: { access: 'token' }, // TS error: 'query' does not exist
})
This gives a type error because Tuyau uses different type extractors for GET vs non-GET:
- GET/HEAD:
ExtractQueryForGet<T> — takes all flat validator properties (minus params/headers/cookies) as query
- POST/PUT/PATCH/DELETE:
ExtractQuery<T> — only recognizes query if the validator has an explicit query property
So for non-GET, flat validator props become body, not query. The workaround is to send access in body instead — AdonisJS request.all() merges body + qs flat, so the validator receives it either way. But it feels wrong to send query-like params in the body of a DELETE request.
Is there a recommended way to define query params in validators for non-GET requests? I noticed ExtractQuery<T> looks for a query key, but AdonisJS's request.validateUsing() doesn't populate a query key — it uses qs for query string data. So adding query: vine.object({...}) to the validator would fix Tuyau types but break runtime validation.
I have a DELETE endpoint that needs an optional
accessquery param:On the client side, I want to pass
accessas a query param:This gives a type error because Tuyau uses different type extractors for GET vs non-GET:
ExtractQueryForGet<T>— takes all flat validator properties (minusparams/headers/cookies) as queryExtractQuery<T>— only recognizes query if the validator has an explicitquerypropertySo for non-GET, flat validator props become
body, notquery. The workaround is to sendaccessinbodyinstead — AdonisJSrequest.all()merges body + qs flat, so the validator receives it either way. But it feels wrong to send query-like params in the body of a DELETE request.Is there a recommended way to define query params in validators for non-GET requests? I noticed
ExtractQuery<T>looks for aquerykey, but AdonisJS'srequest.validateUsing()doesn't populate aquerykey — it usesqsfor query string data. So addingquery: vine.object({...})to the validator would fix Tuyau types but break runtime validation.