-
-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object encoding in query parameters #606
Comments
Just realized that it may not be the intended usage for query parameters to be anything beyond strings: https://elysiajs.com/validation/schema-type#query If thats the case, maybe it would make sense to only every allow strings or optional strings to be passed as query schema to the handler? |
Object encoded query is implemented in 1.0.23, let me know if it works or not |
Hi @SaltyAom, unfortunately I get some errors when I try to use object encoded queries: server.get(
"/domain/:domainId/user",
({ params, query }) => {
// this is a prisma db query
return db.user.findMany({
where: {
domainId: params.domainId,
roles: query?.role
? {
some: query.role,
}
: undefined,
},
});
},
{
response: t.Array(User),
query: t.Optional(
t.Object({
// role: t.Optional(t.String()),
role: t.Optional(t.Object({ id: t.Optional(t.String()) })),
}),
),
},
) results in
which is probably not what should happen ? :D When using this endpoint from the treaty client like this: .user.get({
query: {
role: {
id: "054ce000-cc5a-4e5b-a7e1-1cfd45c18c3f",
},
},
}); I get
instead. I have normalization enabled. |
Should I open a new issue? |
Should be related to #677, let me know if the latest commit fix the problem |
Still seeing this issue.
Where the validation is: query: t.Object({
ids: t.Union([t.Array(t.Numeric()), t.Numeric()])
}) On ElysiaJS 1.0.25 |
Just some additional feedback related to query parameters. Trying to set up query param validations for sorting, filtering, grouping and such is very difficult right now. Would be awesome to see some design patterns, even something that would combine Drizzle ORM and ElysiaJS for filtering on a data table for strings, numbers, and dates. |
@MatthewAry should be fixed in 1e0331f, including test case, published under 1.0.27 |
Still getting the same issue, object aren't being encoded using eden + elysia. |
update: this has been fixed in latest eden release |
Calling the API via the treaty encodes objects passed as query params as literally "[object Object]" instead of URL encoding it.
and on the receiving end:
results in
Is this as it should work and we are just expected to only send primitive values via query parameters?
Thanks!
The text was updated successfully, but these errors were encountered: