Skip to content

Feature Request: Pluggable 'Headers' API Implementation #279

@basicdays

Description

@basicdays

Hello all 👋

I'm currently trying out apollo-link-rest via a node script, and ran into issues with how it expects to use Headers class off of the global object. I'm currently using the cross-fetch package to pull in a fetch ponyfill and passing it into the RestLink constructor via the customFetch option. However there doesn't seem to be a way to do that with the Headers object as well. I'm currently just fully polyfilling the Headers class on the global object, but would like to be able to pass it in via the constructor on a customHeaders option instead.

Proposal:

const { fetch, Headers} = require("cross-fetch");
const { RestLink } = require("apollo-link-rest");

const restLink = new RestLink({
	... // other options
	customFetch: fetch,
	customHeaders: Headers,
});

Workaround:

const { fetch, Headers} = require("cross-fetch");
const { RestLink } = require("apollo-link-rest");

global.Headers = Headers;

const restLink = new RestLink({
	... // other options
	customFetch: fetch,
});

For the sake of easily replicating this, I've added a repository that reproduces this: https://github.com/basicdays/ghtest

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions