mll-lab / laravel-graphql-playground

This project is deprecated in favor of https://github.com/mll-lab/laravel-graphiql.
MIT License
267 stars 25 forks source link

How to pass headers ? #15

Closed sadhakbj closed 5 years ago

sadhakbj commented 5 years ago

For the protected / guarded routes I need to pass the JWT token , how can I do this with Larvel graphql playground ?

mfn commented 5 years ago

You configured a Laravel Middleware for it and tell graph-playground to use it via https://github.com/mll-lab/laravel-graphql-playground/blob/dd014d8edfe7b845a22e1612b935f6055e99c960/config/graphql-playground.php#L9-L12

sadhakbj commented 5 years ago

This is not the solution that I need, this config will basically prevent me from viewing the playground.

I am using Laravel passport for JWT authentication. Inside my schema.graphql i have the following query:

 categories: [Category] @all @middleware(checks: ["auth:api"])

I want to get access to this query in the same that we used to do for the restful APIS by passing the JWT token (probably from the playground for testing) .

The query in my playground to get the categories looks like:

query {
  categories {
  name
}
}

When I press the run button I get the following error:

"errors": [
    {
      "debugMessage": "Route [login] not defined.",
      "message": "Internal server error",
      "category": "internal",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "categories"
      ],

I want to implement the authentication using Laravel Lighthouse and playground.

spawnia commented 5 years ago

image

Does that answer your question?

sadhakbj commented 5 years ago

@spawnia I will give it a try.

I have created one issue on the lighthouse repository. I am getting error trying to implement the auth:api middleware: https://github.com/nuwave/lighthouse/issues/579

spawnia commented 5 years ago

Alright. It seems that this issue does not really concern this repo though, since it seems to be a more general problem with authentication. This is really only a thin integration layer for GraphQL Playground.

josevalero commented 3 years ago

imagen

@sadhakbj maybe that answer your question !!

sadhakbj commented 3 years ago

@josevalero yes the issue was solved long back