Our solution
Accept file uploads through your GraphQL API with no second endpoint
Cosmo Router implements the GraphQL multipart request specification. Clients send a multipart/form-data request with three parts: operations, map, and file parts. Declare an Upload scalar in your schema and you can accept files from any spec-compliant client.
The three parts
- operations: the GraphQL query with file variables set to
null - map: associates file fields to variable paths
- file parts: the actual bytes
At request time
Instead of splitting uploads onto a separate REST service, callers use the same federated GraphQL URL they already use for reads and mutations. The router accepts a multipart body, interprets it according to the spec, and continues the request as normal GraphQL work.
The router parses the payload, validates the mapping, and attaches each file to the correct variable before federation routes the mutation.
Declare an `Upload` scalar in your schema and implement it in the resolver layer: any spec-compliant client can send files through the same GraphQL endpoint as everything else.
File size and file count limits are configured on the router in `config.yaml`; malformed multipart requests are rejected at the router.
One endpoint. Standard tooling. Binary on the wire.

