graphql / graphql-playground

🎮 GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)
MIT License
8.77k stars 734 forks source link

How add cookies in request #1073

Open zhaogaolong opened 5 years ago

zhaogaolong commented 5 years ago

This issue pertains to the following package(s):

What OS and OS version are you experiencing the issue(s) on?

mac os 10.14.6

What version of graphql-playground(-electron/-middleware) are you experiencing the issue(s) on?

verssion 1.8.10 (1.8.10.5129)

how add cookies in request.

andylacko commented 5 years ago

Don't know if it helps, it helped me. Try checking this 'request.credentials': 'omit', // possible values: 'omit', 'include', 'same-origin'

I set it to include and it started working after calling login mutation

axos88 commented 4 years ago

Apparantly adding the HTTP-HEADER is swallowed, even with request.credentials set to incude. Setting the cookie from the dev tools also doesn't seem to work. Executing document.cookie = "a=4" doesn't set the cookie in the application view.

Any other workarounds on how to inject cookies?

axos88 commented 4 years ago

Using the desktop app, version 1.7.20

axos88 commented 4 years ago

Hmm. Apparantly I'm using 1.8.10, but the lower right corner in the settings view shows 1.7.20. How is this possible?

evgenyt1 commented 4 years ago

Using the desktop app, version 1.7.20

Same problem for me 1.7.20 in corner (1.8.10 in CMD+,)


  "editor.cursorShape": "line",
  "editor.fontFamily": "'Source Code Pro', 'Consolas', 'Inconsolata', 'Droid Sans Mono', 'Monaco', monospace",
  "editor.fontSize": 14,
  "editor.reuseHeaders": true,
  "editor.theme": "dark",
  "general.betaUpdates": false,
  "prettier.printWidth": 80,
  "prettier.tabWidth": 2,
  "prettier.useTabs": false,
  "request.credentials": "include",
  "schema.disableComments": true,
  "schema.polling.enable": true,
  "schema.polling.endpointFilter": "*localhost*",
  "schema.polling.interval": 200000,
  "tracing.hideTracingResponse": true
}```
wassafr commented 4 years ago

@andylacko's solution works for me on 1.7.23 in Chrome.

I had to reload the page to make it work.

multic0nt3xt commented 4 years ago

I have this problem too. can't add cookie to http headers. also when i examine the headers in browser, noticed that Content-Type sent in lowercase like "content-type". and when i open settings, it shows version 1.7.20 in right bottom corner. my version: 1.8.10 please fix these problems. thanks

ghost commented 4 years ago

If you're here because you're attempting to authenticate to access services by spoofing cookies, consider instead using the Authorize header in the HTTP HEADERS section of the Playground as explained here for Reaction Commerce (as an example):

https://docs.reactioncommerce.com/docs/developer-authentication#how-to-get-an-access-token-for-development

mmatela commented 4 years ago

Nothing worked for me either. Had to switch GraphQL Playground to Insomnia Core, no such problems there.

xap5xap commented 3 years ago

I had to use GraphiQL. It allows to add cookies easily

vegerot commented 2 years ago

How can I do this using the GraphQL Playground desktop app?