Is your feature request related to a problem? Please describe.
Server implementation converts params of request to array with order specified in my own open-rpc document.
I found this a little strange and inconsistent with behavior of client implementation (it is doesn't change params structure if i send params as object with fields).
It also does not allow to have same method interface between frontend and backend.
Altogether, why it is bad?:
Different client/server method interface, cannot be used in front/back monorepo
Cannot be used as drop-in replacement lib without breaking backward compatibility of current services
Under the hood params convertation magic
Describe alternatives you've considered
I could move all params under the user or data parent object, but [see 2nd clause]
Describe the solution you'd like
I would prefer global or method-by-method option to choose params structure
Option to choose preferred params structure
Choose params structure from open-rpc document methods[#].paramStructure (breaking current behavior)
Additional context
Example:
interface CreateUserParams {
name: string;
age: number;
// many other fields
}
// Client side:
class UserService {
client: Client; // open-rpc client
create(params: CreateUserParams) {
this.client.request({
method: "users.create",
params: params
});
}
}
// Server side:
class UserService {
create(params: CreateUserParams) {
console.log(params.name, params.age);
}
}
const userService = new UserService();
const methodMapping = {
"users.create": userService.create.bind(userService)
};
Is your feature request related to a problem? Please describe. Server implementation converts params of request to array with order specified in my own open-rpc document. I found this a little strange and inconsistent with behavior of client implementation (it is doesn't change params structure if i send params as object with fields). It also does not allow to have same method interface between frontend and backend. Altogether, why it is bad?:
Describe alternatives you've considered I could move all params under the
user
ordata
parent object, but [see 2nd clause]Describe the solution you'd like I would prefer global or method-by-method option to choose params structure
methods[#].paramStructure
(breaking current behavior)Additional context Example: