Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support passing custom fetch into GraphQLClient constructor #178

Closed
wants to merge 2 commits into from

Conversation

tarekrached
Copy link

Addresses #40, needs documentation and tests.

Use like so:

import { GraphQLClient } from 'graphql-request'

const client = new GraphQLClient(endpoint, { fetch: myCustomFetch })

@tarekrached tarekrached changed the title enable passing custom fetch into GraphQLClient constructor options feat: support passing custom fetch into GraphQLClient constructor Jul 20, 2020
@saurabh-codeword
Copy link

saurabh-codeword commented Jul 30, 2020

I use this library in node, and this feature will make it easier.

currently I have to do this:

import fetch from 'node-fetch'

// @ts-ignore
if (!global.fetch) {
  // @ts-ignore
  global.fetch = fetch
}

@jasonkuhrt
Copy link
Member

@saurabh-codeword You shouldn't have to do that anymore.

Copy link
Member

@jasonkuhrt jasonkuhrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tarekrached this doesn't address the aspect of #40 which is about bundle size.

But anyways let's get this merged.

Yes please add docs and tests.

@fischerman
Copy link
Contributor

This PR is a great addition to enable writing API tests since you can have multiple cookie jars.

@tarekrached
Copy link
Author

Heads-up - I'm pretty slammed at my day job, so I'm having trouble finding time to add the tests and documentation. If someone wants to pick this up, please go for it! (We're using an internal build off this branch so we are unblocked.)

@tarekrached
Copy link
Author

superseded by #212

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

Successfully merging this pull request may close these issues.

4 participants