connectrpc / connect-query-es

TypeScript-first expansion pack for TanStack Query that gives you Protobuf superpowers.
https://connectrpc.com/docs/web/query/getting-started
Apache License 2.0
218 stars 14 forks source link

Get Method with other query params #392

Open KamalSunar opened 1 month ago

KamalSunar commented 1 month ago

Hi,

I am using CRA with protobuf to generate proto files and adding generated proto query

export const getGenericList = { localName: "getGenericList", name: "getGenericList", kind: MethodKind.Unary, I: genericDetailsRequest, O: genericDetailsResponse, service: { typeName: "bfi.application_setting.rpc.ApplicationSettingService" } } as const;

while i am using this as const { data } = useQuery({ ...getGenericList, idempotency: MethodIdempotency.NoSideEffects, // for GET method }); but whever i am calling an API, it adds other query params like

connect: v1 encoding: octet-stream base64: 1 message: CgR0ZXN0 on url which i dont need.

e.g https://**/v1/bfi.application_setting.rpc.ApplicationSettingService/getGenericList?connect=v1&encoding=octet-stream&base64=1&message=

how to pass custom query and use GET method on connect-query without autogenerated query params.

timostamm commented 1 month ago

Hi Kamal,

Connect GET uses the following query parameters:

If you use Protobuf binary (useBinaryFormat: true in your transport), the base64=1 parameter is required, because binary data cannot be encoded in query parameters, and base64 makes it safe to encode.

If you use JSON (omit the useBinaryFormat option in your transport), the base64 query parameter is not needed, and will not be included in the URL.

You can find the specification here.

You cannot remove these query parameters because they are required by the server to parse the request. You cannot add query parameters because the server will most likely not understand them, since they would not be part of the schema defined in Protobuf.