Those two parts are and for some reason when I run them separately it works fine, but when I decide to join them together (meaning running the Mesh with the OpenAPI Source, and the getExecutorForUnifiedGraph) it gives me the following result:
{
errors: [
TypeError: You should have fetch defined in either the config or the context!
at field.resolve (file:///usr/src/app/node_modules/@graphql-mesh/transport-rest/esm/directives/httpOperation.js:229:20)
at executeField (file:///usr/src/app/node_modules/@graphql-tools/executor/esm/execution/execute.js:317:24)
at executeFields (file:///usr/src/app/node_modules/@graphql-tools/executor/esm/execution/execute.js:265:28)
at executeOperation (file:///usr/src/app/node_modules/@graphql-tools/executor/esm/execution/execute.js:225:18)
at file:///usr/src/app/node_modules/@graphql-tools/executor/esm/execution/execute.js:65:45
at new ValueOrPromise (/usr/src/app/node_modules/value-or-promise/build/main/ValueOrPromise.js:14:21)
at executeImpl (file:///usr/src/app/node_modules/@graphql-tools/executor/esm/execution/execute.js:65:20)
at execute (file:///usr/src/app/node_modules/@graphql-tools/executor/esm/execution/execute.js:48:12)
at file:///usr/src/app/node_modules/@graphql-tools/executor/esm/execution/normalizedExecutor.js:12:37
at new ValueOrPromise (/usr/src/app/node_modules/value-or-promise/build/main/ValueOrPromise.js:14:21) {
path: [Array],
locations: undefined,
extensions: [Object: null prototype] {}
}
],
data: [Object: null prototype] { feed_availability: null }
}
I did find in this page that I can pass my own fetch as a parameter of the Mesh, but trying it out with node-fetch or whatwg-node/fetch won't solve it.
I did however find a temporary solution,which is adding this two lines inthe httpOperation.js file of the graphql-mesh
This one in the line 9:
import { createGraphQLError, memoize1 } from '@graphql-tools/utils';
import { Blob, File, FormData, URLSearchParams, fetch as whatwgFetch } from '@whatwg-node/fetch';
import { isFileUpload } from './isFileUpload.js';
Basically this solution is adding a fallback for the whatwgFetch in case there is no other fetch being define.
I was wondering if I should open this issue in the GraphQL Mesh repo, but since it works fine with the normal npx hive-gateway supergraph supergraph.js, and only has this error when using the getExecutorForUnifiedGraph I decided to open this here.
Here is a repo in which you can reproduce this error: hive-fetch-error
I was trying to follow two parts of a tutorial for GraphQL Mesh:
Those two parts are and for some reason when I run them separately it works fine, but when I decide to join them together (meaning running the Mesh with the OpenAPI Source, and the getExecutorForUnifiedGraph) it gives me the following result:
I did find in this page that I can pass my own fetch as a parameter of the Mesh, but trying it out with node-fetch or whatwg-node/fetch won't solve it.
I did however find a temporary solution,which is adding this two lines inthe httpOperation.js file of the graphql-mesh
This one in the line 9:
And this one in the line 223:
Basically this solution is adding a fallback for the whatwgFetch in case there is no other fetch being define.
I was wondering if I should open this issue in the GraphQL Mesh repo, but since it works fine with the normal
npx hive-gateway supergraph supergraph.js
, and only has this error when using thegetExecutorForUnifiedGraph
I decided to open this here.Here is a repo in which you can reproduce this error: hive-fetch-error