question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG]: execute link gives an error in 3.7.0

See original GitHub issue

Intended outcome:

I use this function to execute an introspection query to my GraphQL server.

import { execute, HttpLink, toPromise, gql } from "@apollo/client";
import { get, map, filter, pick, isFunction } from "lodash";
import { getIntrospectionQuery, buildClientSchema, introspectionFromSchema } from "graphql";

/**
 * Function that executes a query to get our schemas.
 * For details see: https://www.apollographql.com/docs/resources/graphql-glossary/#introspection
 *
 * @param {Function} - callback function to execute when query resolves.
 * @param callback
 */
async function introspectionQuery (callback) {
	const link = new HttpLink({ uri: process.env.GRAPHQL_URL });

	console.log("introspectionQuery called", process.env.GRAPHQL_URL);

	// For single execution operations, a Promise can be used
	await toPromise(execute(link, {
		query: gql(getIntrospectionQuery()),
	})).then(({ data }) => {
		console.log("introspectionQuery executed", data);

		// store information about schema types to be used with IntrospectionFragmentMatcher
		global.fragmentTypes = {
			__schema: {
				types: map(filter(get(data, "__schema.types", []), type => type.possibleTypes !== null), type => pick(type, ["kind", "name", "possibleTypes"])),
			},
		};

		// store stringified version of schema types to send to client
		global.unionsInterfaceTypes = JSON.stringify(global.fragmentTypes).replace(/</g, "\\u003c");

		// build and store schemas to be used with bridge for uniforms library
		global.schema = buildClientSchema(data);

		// store stringified version of schemas to send to client
		global.schemaString = JSON.stringify(get(data, "__schema", {})).replace(/</g, "\\u003c");
	}).catch(error => console.log(`introspectionQuery received error ${error}`));

	// execute callback
	if (isFunction(callback)) callback();
}

Using @apollo/client@3.6.9 this works as intended and returns me the result of the query.

Actual outcome:

Using @apollo/client@3.7.0 this does not work anymore and returns the following error:

TypeError: headers.hasOwnProperty is not a function

How to reproduce the issue:

I don’t have a working repo right now, but if required I can make one.

Versions

Working version

System:
    OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
  Binaries:
    Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
  npmPackages:
    @apollo/client: ^3.6.9 => 3.6.9 

Failing version

System:
    OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
  Binaries:
    Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
  npmPackages:
    @apollo/client: ^3.7.0 => 3.7.0 

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
leepowellnbscommented, Oct 20, 2022

@simplecommerce Thanks for the update, seems we too were using an old version of isomorphic-fetch as a polyfill for our jest tests, upgrading to the latest version has fixed it!

0reactions
simplecommercecommented, Oct 19, 2022

Ok I figured out my problem, my project runs Meteor and I was using isomorphic-fetch@2.2.1. I installed the latest version 3.0.0 and it works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

BUG: Cannot compile for 3.11 · Issue #16262 · scipy ... - GitHub
Command I used - pip install --no-cache-dir --upgrade scipy and my pip is the latest version (pip 22.1.1 from ...
Read more >
cx freeze - cx_Freeze crashing Python 3.7.0 - Stack Overflow
The fix for this bug exists: pull request 395: Compilation correct .pyc files for Python 3.7.0. You can apply it by hand to...
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
Bug :1523 - "[IDEA] Offload work by distributing trivial ebuild maintenance to users, introduce a simple stability voting system and have a core...
Read more >
Red Hat Quay Release Notes
RHBA 2022:8786 - Red Hat Quay 3.7.11 bug fix update. Expand section "1. ... Quay 3.7.0 API update default quota should not return...
Read more >
Changelog - Cypress Documentation
Fixed an edge-case bug where Cypress would hang in run-mode if an error was thrown from a test:before:run event handler. Fixes #23039. Fixes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found