graphql-playground icon indicating copy to clipboard operation
graphql-playground copied to clipboard

How add cookies in request

Open zhaogaolong opened this issue 5 years ago • 11 comments

This issue pertains to the following package(s):

  • [ ] GraphQL Playground - Electron App
  • [ ] GraphQL Playground HTML
  • [x] GraphQL Playground
  • [ ] GraphQL Playground Express Middleware
  • [ ] GraphQL Playground Hapi Middleware
  • [ ] GraphQL Playground Koa Middleware
  • [ ] GraphQL Playground Lambda Middleware

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.

zhaogaolong avatar Aug 23 '19 08:08 zhaogaolong

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

andylacko avatar Aug 30 '19 08:08 andylacko

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 avatar Jan 07 '20 09:01 axos88

Using the desktop app, version 1.7.20

axos88 avatar Jan 07 '20 09:01 axos88

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?

axos88 avatar Jan 07 '20 09:01 axos88

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
}```

evgenyt1 avatar May 10 '20 17:05 evgenyt1

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

I had to reload the page to make it work.

wassafr avatar Jul 27 '20 20:07 wassafr

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

multic0nt3xt avatar Aug 03 '20 07:08 multic0nt3xt

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

ghost avatar Aug 20 '20 07:08 ghost

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

mmatela avatar Sep 28 '20 15:09 mmatela

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

xap5xap avatar Dec 31 '20 13:12 xap5xap

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

vegerot avatar May 12 '22 00:05 vegerot