GraphQL Upload
In gqless you can add File Upload support easily, following the GraphQL multipart request specification.
Preparation#
Normally, in the API servers, they implement graphql-upload, inbuilt in Apollo Server, or via mercurius-upload for Fastify.
Meanwhile in the client, to follow the GraphQL multipart spec, you can easily use extract-files.
- pnpm
- npm
- yarn
And then, use it in your QueryFetcher, like the following example:
Compatible with browser's File and Blob, and React Native using ReactNativeFile
Usage#
Core#
Since the images are not serializable, gqless might be confused while
using them, that's why you have to specify a special option nonSerializableVariables in your resolveds
React#
Since the images are not serializable, gqless might be confused while
using them, that's why you have to specify a special option nonSerializableVariables in your useMutations