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
message unreceivable without first decoding from base64 #14
Comments
@nateq314 function commonMessageHandler ({attributes = {}, data = ''}) {
return {
...attributes,
text: data.toString()
}
} If you publish non string data it gets stringified and you have to parse the received message data as you did above.
With the commonMessageHandler you are quite flexible with what you can do with the received message. Let me know if you have any non breaking suggestions which would improve this handling. |
@nateq314 graphql-google-pubsub/src/test/tests.ts Line 223 in 7e70c8f
Also there could be anything else in the buffer apart from a simple string. |
I had the same issue. Maybe this explanation could be added to the README because by just following the instructions there, you only get that |
@nateq314 @ivosequeros thx for the feedback. Will move this information over to the readme as soon as I find time. |
Was following the setup instructions per the readme and just spent a really long time debugging an issue that was causing the following
to be received each time. (I modified it a tiny bit and replace "id" with "message".)
Schema was:
Resolver was:
Basically everything almost exactly per the instructions, but I kept getting
null
. I tried both 1) directly publishing a message via the Pub/Sub GUI on Google Cloud Console, and2) setting up a dummy mutation as follows, and calling it:
Both kept resulting in
null
.What finally fixed it was adding a
resolve()
method to thesomethingChanged
subscription which decodes from base64, as follows:Or putting the same into
commonMessageHandler
:with
resolve()
just passing on the payload as is (doesn't work without this):Google's own docs clearly state that base64 is necessary (https://cloud.google.com/pubsub/docs/publisher). So given that this is a Google-cloud-specific package, isn't this the kind of thing that ought to be handled behind the scenes by the package? Am I doing something wrong? Has anybody else run into this?
The text was updated successfully, but these errors were encountered: