Why should I use all Absinthe packages on the frontend?

Hi. I’m using Elixir with Phoenix and Absinthe for providing GraphQL API via http and websocket. I’ve just covered Absinthe docs section about integrating with frontend. I checked all recommended npm integration libraries and I just didn’t get what they do that Apollo can’t on themselves (for example I saw Observer implementation in sources and it’s exist in Apollo too)? Would my client works properly with Phoenix socket using such raw setup from Apollo docs?

import { WebSocketLink } from '@apollo/client/link/ws';

const wsLink = new WebSocketLink({
  uri: `ws://localhost:5000/`,
  options: {
    reconnect: true,
    connectionParams: {
      authToken: user.authToken,
    },
});

I’m sure that using they is reasonable just want to know why

Phoenix doesn‘t use raw websockets, but it‘s phoenix channels over websockets. There are ways to make it work without the cliebt lib, but you‘ll need do adapt the server side to be able to receive data in whatever format it is sent by apollo instead of the format the phoenix client library uses.

2 Likes

it’s reasonable. On the other side it looks like possible to implement it via Phx_raws - Raw websocket on top of Phoenix. Will dig in, thanks