# Assigning proper type for schema field that is to store Node.js buffer array (saving decoded base64 JSON image data)

**URL:** <https://community.apollographql.com/t/assigning-proper-type-for-schema-field-that-is-to-store-node-js-buffer-array-saving-decoded-base64-json-image-data/6289>\
**Category:** Server\
**Tags:** server\
**Created:** [May 22, 2023, 12:36pm UTC](https://community.apollographql.com/t/assigning-proper-type-for-schema-field-that-is-to-store-node-js-buffer-array-saving-decoded-base64-json-image-data/6289 "2023-05-22T12:36:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcomp-03](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/jcomp-03/32/4300_2.png) [@jcomp-03](https://community.apollographql.com/u/jcomp-03)\
**Post date:** [May 22, 2023, 12:36pm UTC](https://community.apollographql.com/t/assigning-proper-type-for-schema-field-that-is-to-store-node-js-buffer-array-saving-decoded-base64-json-image-data/6289/1 "2023-05-22T12:36:34Z")

</div>

Hi everyone.  
My situation is the following:  
I’m integrating OpenAI’s DALLE-2 API into my web app. The generated picture is returned as a base64-encoded json string, which I am converting into Node.js buffer type:

```auto
function decodeBase64JsonAndSaveAsBuffer(b64jsonString) {
    let binData = Buffer.from(b64jsonString, 'base64');
    return binData;
}

```

The return from this function is saved as Mongoose schema type Buffer in my image’s schema/model. I think I have all this right up to that point. Now, however, GraphQL complains that the String type I have assigned to the **binData** field for my Image type can’t represent a buffer array:

 ![graphql_error](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/3/3972cbaa0be87d3db5ea6f1c4c2b2b13e1232f18.jpeg)

Ok, I understand I need to change the type for this field. The question is, to what do I change it in light of I need to handle this Nodejs buffer array input?

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:48pm UTC](https://community.apollographql.com/t/assigning-proper-type-for-schema-field-that-is-to-store-node-js-buffer-array-saving-decoded-base64-json-image-data/6289/2 "2025-02-06T20:48:51Z")

</div>


