JSON API compliant channel communication

I’m wondering how I can make my channel communication (with front-end) JSON API compliant ( http://jsonapi.org/)? I have used js_serializer in controllers, but how to go about it in socket communication? And please correct me if I’m wrong, but it looks like the default communication is in JSON. Where is this format defined and who is doing the serialization/deserialization?

Another noob question: Does it even make sense to talk about message formats in socket communication? I guess it does, but I’m not sure. I say that because it doesn’t look like there’s any place to specify content type or anything in socket communication.

1 Like

I push / broadcast elixir maps, f.e. push socket, “newTaskCurrentUser”, resp, where resp is a map. You can see in the browser console that it is received as a json.

I’m actually talking about the JSON API standard: http://jsonapi.org/ (I’ve edited the question to reflect this) but I think it can’t be done with something like ja_serializer. Since there are no models directly associated with channels, there’s no way to serialize things in a straightforward manner. I guess I’ll have to do it the hard way.

One of the nice things about GraphQL being transport agnostic is that you could easily just send graphql docs through a channel, and then have the channel push out data according to what was queried. GraphQL also has a first class concept of subscriptions which we’re hoping will map onto channels very nicely.

JSON API seems to see itself as a way to do REST well, and thus is stuck to scenarios where REST makes sense.

2 Likes

Yes . . . I’ve looked at GraphQL briefly and it does seem to be the right way to do things. At this moment I just don’t have the time to dive into server-side implementation. But you’ve raised an important point.