
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
gullitmiranda-apollo-upload-client
Advanced tools
Enhances Apollo Client for intuitive file uploads via GraphQL mutations.
Enhances Apollo for intuitive file uploads via GraphQL mutations or queries. Use with apollo-upload-server.
Install with npm:
npm install apollo-upload-client
Setup Apollo Client with a special network interface:
import ApolloClient from 'apollo-client'
import { createNetworkInterface } from 'apollo-upload-client'
const client = new ApolloClient({
networkInterface: createNetworkInterface({
uri: '/graphql'
})
})
Alternatively enable query batching:
import ApolloClient from 'apollo-client'
import { createBatchingNetworkInterface } from 'apollo-upload-client'
const client = new ApolloClient({
networkInterface: createBatchingNetworkInterface({
uri: '/graphql'
})
})
Also setup apollo-upload-server.
Once setup, you will be able to use FileList
, File
and ReactNativeFile
instances anywhere within mutation or query input variables.
With apollo-upload-server
setup, the files upload to a temp directory. Upload
input type metadata replaces file instances in the arguments received by the resolver. See the server usage.
See server usage for this example.
import React from 'react'
import { graphql, gql } from 'react-apollo'
export default graphql(gql`
mutation updateUserAvatar($userId: String!, $avatar: Upload!) {
updateUserAvatar(userId: $userId, avatar: $avatar) {
id
}
}
`)(({ userId, mutate }) => {
const handleChange = ({ target }) => {
if (target.validity.valid) {
mutate({
variables: {
userId,
avatar: target.files[0]
}
}).then(({ data }) => console.log('Mutation response:', data))
}
}
return (
<input
type="file"
accept={'image/jpeg,image/png'}
required
onChange={handleChange}
/>
)
})
See server usage for this example.
import React from 'react'
import { graphql, gql } from 'react-apollo'
export default graphql(gql`
mutation updateGallery($galleryId: String!, $images: [Upload!]!) {
updateGallery(galleryId: $galleryId, images: $images) {
id
}
}
`)(({ galleryId, mutate }) => {
const handleChange = ({ target }) => {
if (target.validity.valid) {
mutate({
variables: {
galleryId,
images: target.files
}
}).then(({ data }) => console.log('Mutation response:', data))
}
}
return (
<input
type="file"
accept={'image/jpeg,image/png'}
multiple
required
onChange={handleChange}
/>
)
})
React Native polyfills FormData under the hood and objects with the properties uri
, type
and name
substitute window.File
. It would be risky to assume all objects with those properties in variables are files. Use ReactNativeFile
instances in query or mutation variables to explicitly mark files for upload:
import { ReactNativeFile } from 'apollo-upload-client'
// ✂
// Single file
const file = new ReactNativeFile({
uri: uriFromCameraRoll,
type: 'image/jpeg',
name: 'photo.jpg'
})
// Multiple files
const files = ReactNativeFile.list({
uri: uriFromCameraRoll1,
type: 'image/jpeg',
name: 'photo-1.jpg'
}, {
uri: uriFromCameraRoll2,
type: 'image/jpeg',
name: 'photo-2.jpg'
})
// ✂
FAQs
Enhances Apollo Client for intuitive file uploads via GraphQL mutations.
The npm package gullitmiranda-apollo-upload-client receives a total of 8 weekly downloads. As such, gullitmiranda-apollo-upload-client popularity was classified as not popular.
We found that gullitmiranda-apollo-upload-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.