Skip to content
This repository has been archived by the owner on Feb 10, 2019. It is now read-only.

Access HTTP headers from php Query resolver? #364

Open
ericfong opened this issue Jul 30, 2018 · 3 comments
Open

Access HTTP headers from php Query resolver? #364

ericfong opened this issue Jul 30, 2018 · 3 comments

Comments

@ericfong
Copy link

can I access HTTP headers from php Query resolver?

I want to access the 'User-Agent', 'Accept-Language' and some other custom HTTP header from resolver.

Thanks a lot

@mfn
Copy link

mfn commented Jul 30, 2018

Yes, do it "the Laravel" way:

  • either inject Request in your constructor
  • or access app('request') where you need it.

@ericfong
Copy link
Author

Thanks.

@mfn
Copy link

mfn commented Jul 30, 2018

There's yet another way:

  • you can make your own GraphQLController (extend it and specify it in your config/graphql.php)
  • override queryContext and add it do the context right from the start

This way your resolver does not just receive User $user (the third arg) but e.g. ['user' => …, 'request' => …]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants