keystonejs / keystone

The superpowered headless CMS for Node.js — built with GraphQL and React
https://keystonejs.com
MIT License
9.18k stars 1.15k forks source link

use image in document field #8389

Open matinst opened 1 year ago

matinst commented 1 year ago

Hi, I want to use the image in the document field and I use this solution in code => AcademyFAQ: list({ access: allowAll, fields: { title: text(), description: document({ formatting: true, links: true, relationships:{ asset:{ listKey:'Asset', label:'Asset', selection:'title image' } } }), assets:relationship({ ref:"Asset.academyFAQ", many:true }) }, }),

Asset: list({ access:allowAll, fields:{ title: text(), image: image({ storage:'minio' }), academyFAQ: relationship({ref:'AcademyFAQ.assets',many:false}) } })

but when I use it, I got this error in the description field after creating data with the image Field "image" of type "ImageFieldOutput" must have a selection of subfields. Did you mean "image { ... }"?

ganobrega commented 1 year ago

Hi @matinst!

It's look like you need to get subfields of your image field.

query {
    assets(where: { **** } ) {
+    image { id, filesize, width, height, url }        
    }
}

Use the IDE to look for the Type Definition or try to find in the Keystone repository.

https://github.com/keystonejs/keystone/blob/2ec8700ae005c4f22dda6b9e6a68e847478c56a4/packages/core/src/fields/types/image/index.ts#L35-L50