small medium large xlarge

24 Mar 2018, 13:43
Adrian Rogers (2 posts)


I’ve just finished reading through the last couple of chapters and had the following questions around the relay framework:

  1. For apollo you explicitly mention how we can connect both via http and ws, however for relay only ws is mentioned, does it support http too?
  2. Is there a way to pass an authentication token through when using relay? There doesn’t seem to be any examples of how you would access any authenticated views in chapter 11 at all.
24 Mar 2018, 17:24
Bruce Williams (20 posts)

Adrian, thanks for reading the book!

  1. You should be able to pass in a standard HTTP fetcher as described in the Relay documentation as the first argument to Network.create. Absinthe’s HTTP support doesn’t require any special wiring.
  2. Unfortunately adding authentication to the chapter (for the multiple approaches shown) would have delved more significantly into JS client-side specifics (and page count) than we wanted to focus on for this edition.

Background: As we talk about in Chapter 8, most people tend to use a mutation that’s something like the following to handle accepting credentials for authentication:

mutation CreateSession($email: String!, $password: String!) {
  createSession(email: $email, password: $password) {

Where createSession returns an object with a token field to be used in future requests.

Now, on the client-side, the token can be stored in state (frequently in local storage) and then:

  • Using HTTP, in an Authorization header sent by the fetcher
  • Using WS, during socket connection (I’ll work on digging up a Relay example; I’m on Apollo usually these days, and things have changed a bit. It’s something that we should document better for our @absinthe/socket-relay npm package and/or in a guide.)

Another suggestion, if you’re not already in there; the absinthe-graphql Elixir Slack channel has a number of developers that have launched Relay apps on top of Absinthe to production; they might be especially helpful with some of the deeper client-side questions.

24 Mar 2018, 21:04
Adrian Rogers (2 posts)

Thank you for the advice, I’ll try using the standard fetcher for now - it looks like it should be easy enough to add a header to that. I’ve also now jumped onto the slack channel so if I get stuck later on I’ll ask around in there.

You must be logged in to comment