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

_isomorphicFetch is not defined #611

Open
spaceninja opened this issue Apr 4, 2024 · 0 comments
Open

_isomorphicFetch is not defined #611

spaceninja opened this issue Apr 4, 2024 · 0 comments
Labels

Comments

@spaceninja
Copy link

spaceninja commented Apr 4, 2024

Environment

  • Operating System: Darwin
  • Node Version: v21.7.1
  • Nuxt Version: 3.11.1
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.5
  • Package Manager: npm@10.5.0
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Describe the bug

I'm using a custom fetch function in httpLinkOptions as detailed here: https://www.apollographql.com/docs/react/api/link/apollo-link-http/#customizing-fetch

Expected behaviour

// nuxt.config.ts:
import apolloConfig from './apollo-config';
export default defineNuxtConfig({
  apollo: apolloConfig,
  modules: ['@nuxtjs/apollo'],
});
// apollo-config.ts
import fetch from 'isomorphic-fetch';
export default {
  clients: {
    default: {
      httpEndpoint: process.env.NUXT_DATOCMS_GRAPHQL_URL,
      httpLinkOptions: {
        headers: {
          Authorization: `Bearer ${process.env.NUXT_DATOCMS_TOKEN}`,
        },
        fetch: (uri: string, options: any) => {
          const fetchBody = JSON.parse(options.body);
          // do some stuff to modify fetchBody
          options.body = JSON.stringify(fetchBody);
          return fetch(uri, options);
        },
      },
    },
  },
};
// example.vue
import sampleQuery from 'sample.gql';
const {
  data: sampleData,
  pending: sampleLoading,
  error: sampleError,
} = useAsyncQuery(sampleQuery);

With this example, sampleError comes back with "_isomorphicFetch is not defined"

After a bit of digging, this is the NetworkError field on the error returned by Apollo: https://www.apollographql.com/docs/react/api/link/apollo-link-error#networkerror

I don't get any console or server errors.

Reproduction

No response

Additional context

No response

Logs

No response

@spaceninja spaceninja added the bug label Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant