I am working on a project that currently uses protobuf to communicate from the client to the api. I would like to do a proof of concept showing communication via graphql, and am wondering if its possible to send protobuf to apollo server instead of json.
also asked in spectrum for apollo server: https://spectrum.chat/apollo/apollo-server/is-there-support-in-the-road-map-at-all-for-sending-protobuf-from-the-client~dbdbc639-d7c7-4d0f-9caa-b58bb3744a90
I see a few protobuf related packages, https://www.npmjs.com/package/apollo-engine-reporting-protobuf https://www.npmjs.com/package/@apollo/protobufjs
and am wondering if there are any plans for this or if it's possible. asking here because i've received no response on the community site.
If you can use
apollo-server-express
, you can achieve that as long as you can convert the protobuf to json again on the server, which I guess it is possible with protobuf.js.apollo-server
orapollo-server-express
expects three key-pair values in the request bodyoperationName
variables
query
This is how request body looks like (logged using morgan-body)
If you are using
apollo-server-express
, you can use your customexpress middleware
in which you can deserialize the protobuf to json and add the json to thereq.body
for Apollo Server.Changing from
apollo-server
toapollo-server-express
just takes a few steps and no change in your apollo server config