GithubHelp home page GithubHelp logo

cookie support about graphql-request HOT 7 CLOSED

jasonkuhrt avatar jasonkuhrt commented on May 26, 2024
cookie support

from graphql-request.

Comments (7)

mwld avatar mwld commented on May 26, 2024

Your problem might be caused by not including credentials: same-origin in your request header (JakeChampion/fetch#386).

This should now be possible with the release of 1.3.2: #9

Like:

new GraphQLClient(YOUR_ENDPOINT_URL, {
    credentials: "same-origin",
});

from graphql-request.

DxCx avatar DxCx commented on May 26, 2024

hey @mwld is that actually working for you?
from what i've found isomrophic-fetch will just ignore cookies (or set-cookie header)
i had to write temporary wrapper to support cookies.. :\

from graphql-request.

mwld avatar mwld commented on May 26, 2024

Yes this is working for me :)

from graphql-request.

DxCx avatar DxCx commented on May 26, 2024

yeah well i forgot to mention that i'm using the library from node and not browser.

from graphql-request.

DxCx avatar DxCx commented on May 26, 2024

You made me dig again with your replay.
i was able to replace my ugly big wrapper with just this line:

global['fetch'] = require('fetch-cookie/node-fetch')(require('node-fetch'))

Now graphql-request just works for node as well.
@schickling i think this is worth mentioning in README.MD
would you like me to open a PR?

NOTE: this won't solve per client cookie, since fetch is global.
if we want to support per GraphQLClient cookie we will need to be able to inject fetch function on client constructor. then we can pass different fetch for each client.

from graphql-request.

schickling avatar schickling commented on May 26, 2024

Thanks a lot for bringing this up @DxCx! It would be great if you could mention it briefly in the readme.

Regarding injecting fetch: Let's keep this issue open to see whether other people also have this problem before we're changing the API. @DxCx can you close this issue and create a new one with this concrete suggestion?

from graphql-request.

DxCx avatar DxCx commented on May 26, 2024

the injection is optional, which means, if no fetch is given in option, it will use fetch as it uses it today. but great! i'll update the README

from graphql-request.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.