keystone icon indicating copy to clipboard operation
keystone copied to clipboard

use image in document field

Open matinst opened this issue 2 years ago • 1 comments

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 { ... }"?

matinst avatar Mar 12 '23 13:03 matinst

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

ganobrega avatar Mar 20 '23 03:03 ganobrega