Adrian, thanks for reading the book!
- 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.
- 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) {
token
}
}
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.