An interoperable multipart form field structure for GraphQL requests, used by various file upload client/server implementations.
It’s possible to implement:
- Batched operations.
- Files nested anywhere within each operation (often in variables).
An “operations object” is an Apollo GraphQL POST request (or array of requests if batching). An “operations path” is an object-path
string to locate a file within an operations object.
A JSON encoded operations object with files replaced with null
.
Each file extracted from the operations object with the operations path as the field name. File fields must follow operations
.
{
query: '…',
operationName: 'updateAvatar',
variables: {
userId: '…',
image: File
}
}
operations
:{"query": "…", "operationName": "updateAvatar", "variables": {"userId": "…", image: null}}
variables.image
{
query: '…',
operationName: 'addToGallery',
variables: {
galleryId: '…',
images: [File, File, File]
}
}
operations
:{"query": "…", "operationName": "addToGallery", "variables": {"galleryId": "…", images: [null, null, null]}}
variables.images.0
variables.images.1
variables.images.2
[
{
query: '…',
operationName: 'updateAvatar',
variables: {
userId: '…',
image: File
}
},
{
query: '…',
operationName: 'addToGallery',
variables: {
galleryId: '…',
images: [File, File, File]
}
}
]
operations
:[{"query": "…", "operationName": "updateAvatar", "variables": {"userId": "…", image: null}}, {"query": "…", "operationName": "addToGallery", "variables": {"galleryId": "…", images: [null, null, null]}}]
0.variables.image
1.variables.images.0
1.variables.images.1
1.variables.images.2