Fork me on GitHub
#graphql
<
2018-10-04
>
domkm13:10:47

There are not root resolvers for operation types but most server libraries support resolver context of some sort, which you can use to add access control data to resolvers. For example, in Lacinia, the execute function takes a context map.

urzds14:10:52

In a resolver, how do I get the scheme/hostname/port a query arrived on?

orestis14:10:05

There should be a :request key on the context.

urzds14:10:14

Hm, not here. Maybe I've got a bug somewhere else.

orestis14:10:24

Are you using Lacinia-pedestal?

timgilbert14:10:24

I'm pretty sure we don't have a :request key, I wonder if that might be a lacinia-pedestal thing. But you should be able to create such a key yourself by just assoc'ing the ring/pedestal/etc request into the context map at the time you call (lacinia/execute) (or just the hostname/port/whatever data you need out of the request)

orestis14:10:54

The request key is exactly a Lavinia-pedestal thing.

orestis14:10:32

And it gives you the raw ring request.

urzds15:10:12

@orestis Yes, lacinia-pedestal. I've now changed the code to use the endpoint the backend is configured to listen on instead of the host/port the request arrived via. Maybe I'll investigate the missing (:request context) later.