jaydenseric / apollo-upload-client

A terminating Apollo Link for Apollo Client that fetches a GraphQL multipart request if the GraphQL variables contain files (by default FileList, File, or Blob instances), or else fetches a regular GraphQL POST or GET request (depending on the config and GraphQL operation).
https://npm.im/apollo-upload-client
1.53k stars 155 forks source link

latest version of the package failed to compile #323

Closed Cavdy closed 10 months ago

Cavdy commented 10 months ago

Hello, I installed the latest version of the package(18.0.1) but my project failed to compile, so I had to revert back to version(17.0.0)

the error message below Android Bundling failed 2616ms Unable to resolve "apollo-upload-client" from "services/client.ts"

MicrosoftTeams-image

jaydenseric commented 10 months ago

Hello, most likely you need to update your imports from apollo-upload-client to be deep imports, as per the v18 changelog entry major changes:

https://github.com/jaydenseric/apollo-upload-client/releases/tag/v18.0.0

  • Removed the package main index module; deep imports must be used. To migrate:

    - import {
    -   createUploadLink,
    -   formDataAppendFile,
    -   isExtractableFile
    - } from "apollo-upload-client";
    + import createUploadLink from "apollo-upload-client/createUploadLink.mjs";
    + import formDataAppendFile from "apollo-upload-client/formDataAppendFile.mjs";
    + import isExtractableFile from "apollo-upload-client/isExtractableFile.mjs";
Cavdy commented 10 months ago

In order for the new import to work for me, I had to add the below code to my metro.config.js

defaultConfig.resolver.sourceExts.push('mjs');