Fork me on GitHub
#graphql
<
2017-11-25
>
admay03:11:00

Is there a way, in Lacinia, to attach information from the request headers to either the args or context map? I have a user ID being passed in through the request headers but can’t access it from within the resolvers. I’m using Lacinia and lacinia-pedestal almost line for line with the tutorial

guy15:11:29

I think you can add it to the context at the execute level

guy15:11:04

(ns user
  (:require
    [clojure-game-geek.schema :as s]
    [com.walmartlabs.lacinia :as lacinia]))

(def schema (s/load-schema))

(defn q
  [query-string]
  (lacinia/execute schema query-string nil nil))

guy15:11:14

So lacinia/execute has two nils at the end

guy15:11:23

I believe the way it works is this

guy15:11:31

schema, query-string, variables then Context

guy15:11:52

If you put your request instead of the last nil, that will be passed to all your resolvers in the ctx

guy15:11:19

however, i’m not certain how it works with lacinia pedestal