"CBOR encode error: unsupported type: Date" - when trying to create composedb document

Hello -

I am having some trouble creating documents and hoping someone can help.

I have created and deployed the following composite -

type TirlLabel @createModel(accountRelation: LIST, description:"TrustlessIRL physical identification label") {
  barcodeId: String! @string(maxLength:12)
  imageData: String! @string(maxLength:500)
  uploadTime: DateTime!

I can see the model when I run composedb model:list so I am pretty sure that part was done correctly (the model id is kjzl6hvfrbw6c65z7bpyak6mgz9maadbucil8sey0lkuy9ebiinbjl0vd9ygal4)

Now I am attempting to create a document using the following query-

mutation createTirlLabelMutation($i: CreateTirlLabelInput!) {
    createTirlLabel(input: $i) {
      document {

My TS code is -

const uploadLabel = async ({ barcodeId, imageData }:{ barcodeId:string, imageData:string }) => {
  const compose = new ComposeClient({ ceramic: config.ceramicClient, definition });
  const session = await createDidSession();
  // throws error here
  const result = await compose.executeQuery(createLabelQuery, {
    i: {
      content: {
        uploadTime: new Date().toISOString(),
  return result;

When I run this function I am getting the following error

  errors: [
    Error: CBOR encode error: unsupported type: Date
        at objectToTokens (file:///C:/Users/jmoro/Desktop/dev/ceramic-uploader/node_modules/cborg/esm/lib/encode.js:184:11)
        at Object (file:///C:/Users/jmoro/Desktop/dev/ceramic-uploader/node_modules/cborg/esm/lib/encode.js:151:9)
        at objectToTokens (file:///C:/Users/jmoro/Desktop/dev/ceramic-uploader/node_modules/cborg/esm/lib/encode.js:186:10)
        at Object (file:///C:/Users/jmoro/Desktop/dev/ceramic-uploader/node_modules/cborg/esm/lib/encode.js:151:9)
        at objectToTokens (file:///C:/Users/jmoro/Desktop/dev/ceramic-uploader/node_modules/cborg/esm/lib/encode.js:186:10)
        at encodeCustom (file:///C:/Users/jmoro/Desktop/dev/ceramic-uploader/node_modules/cborg/esm/lib/encode.js:216:18)
        at Module.encode (file:///C:/Users/jmoro/Desktop/dev/ceramic-uploader/node_modules/cborg/esm/lib/encode.js:239:10)
        at Module.encode (file:///C:/Users/jmoro/Desktop/dev/ceramic-uploader/node_modules/@ipld/dag-cbor/esm/index.js:58:37)
        at Module.encode (file:///C:/Users/jmoro/Desktop/dev/ceramic-uploader/node_modules/multiformats/esm/src/block.js:125:23)
        at encodePayload (file:///C:/Users/jmoro/Desktop/dev/ceramic-uploader/node_modules/dag-jose-utils/src/index.ts:16:29) {
      path: [Array],
      locations: [Array],
      extensions: [Object: null prototype] {}
  data: [Object: null prototype] { createTirlLabel: null }

Please let me know if there is an issue with my formatting or if there is any other info I can provide to help troubleshoot.

Big thanks in advance!


Hi, thanks for reporting this issue.

It seems to be caused by the underlying library we’re using, I opened an issue in the ComposeDB repository to track it: Ensure DateTime scalar inputs are converted to string · Issue #53 · ceramicstudio/js-composedb · GitHub
Please feel free to open a PR to fix it, in the meantime using a String scalar instead of DateTime should address your immediate error.

Appreciate you getting back.

I took a look and replied to your issue.

Let me know what you think.