
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@hyperse/apollo-upload-client
Advanced tools
A terminating Apollo Link for Apollo Client that handles GraphQL file uploads using multipart requests.
A terminating Apollo Link for Apollo Client that handles GraphQL file uploads using multipart requests. When GraphQL variables contain files (FileList, File, or Blob instances), it sends a multipart/form-data request. Otherwise, it falls back to standard GraphQL POST/GET requests based on the configuration and operation type.
npm install @hyperse/apollo-upload-client
# or
yarn add @hyperse/apollo-upload-client
# or
pnpm add @hyperse/apollo-upload-client
import { ApolloClient, InMemoryCache, ApolloLink } from '@apollo/client';
import { UploadHttpLink } from '@hyperse/apollo-upload-client';
const client = new ApolloClient({
cache: new InMemoryCache(),
link: ApolloLink.from([
new UploadHttpLink({
uri: '/graphql',
}),
]),
});
import { ApolloClient, InMemoryCache, ApolloLink } from '@apollo/client';
import { UploadHttpLink } from '@hyperse/apollo-upload-client';
const client = new ApolloClient({
cache: new InMemoryCache(),
link: ApolloLink.from([
new ClientAwarenessLink(),
// Add other links here (e.g., error handling, authentication)
new UploadHttpLink({
uri: '/graphql',
}),
]),
});
import { gql, useMutation } from '@apollo/client';
const UPLOAD_FILE = gql`
mutation UploadFile($file: Upload!, $description: String) {
uploadFile(file: $file, description: $description) {
id
filename
url
}
}
`;
function FileUploadComponent() {
const [uploadFile, { loading, error, data }] = useMutation(UPLOAD_FILE);
const handleFileChange = (event) => {
const file = event.target.files[0];
if (file) {
uploadFile({
variables: {
file: file,
description: 'My uploaded file'
}
});
}
};
return (
<div>
<input type="file" onChange={handleFileChange} />
{loading && <p>Uploading...</p>}
{error && <p>Error: {error.message}</p>}
{data && <p>File uploaded: {data.uploadFile.filename}</p>}
</div>
);
}
const UPLOAD_MULTIPLE_FILES = gql`
mutation UploadMultipleFiles($files: [Upload!]!) {
uploadMultipleFiles(files: $files) {
id
filename
url
}
}
`;
function MultipleFileUploadComponent() {
const [uploadFiles, { loading }] = useMutation(UPLOAD_MULTIPLE_FILES);
const handleFilesChange = (event) => {
const files = Array.from(event.target.files);
if (files.length > 0) {
uploadFiles({
variables: {
files: files
}
});
}
};
return (
<input type="file" multiple onChange={handleFilesChange} />
);
}
The main class that handles file uploads in GraphQL requests.
interface UploadHttpLinkOptions<T extends ExtractableFile> {
// HTTP Link options
uri?: string;
fetch?: WindowOrWorkerGlobalScope['fetch'];
headers?: Record<string, string>;
credentials?: RequestCredentials;
// Upload-specific options
FormData?: typeof FormData;
isExtractableFile?: ExtractableFileMatcher<T>;
formDataAppendFile?: FormDataFileAppender<T>;
}
uri (string, default: /graphql): The GraphQL endpoint URIfetch (function): Custom fetch implementationheaders (object): Additional HTTP headerscredentials (string): Request credentials policyFormData (class): Custom FormData implementationisExtractableFile (function): Custom file detection logicformDataAppendFile (function): Custom file appending logictype ExtractableFile = File | Blob;
Supported file types that can be automatically detected and uploaded.
Utility function to extract files from objects and create upload-ready data.
import {
extractFiles,
isExtractableFile,
} from '@hyperse/apollo-upload-client/extractFiles';
const { clone, files } = extractFiles(
{ file: myFile, data: { nested: { file: anotherFile } } },
isExtractableFile
);
MIT License - see LICENSE file for details.
Made with ❤️ by the Hyperse team
FAQs
A terminating Apollo Link for Apollo Client that handles GraphQL file uploads using multipart requests.
We found that @hyperse/apollo-upload-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.