keystone
keystone copied to clipboard
use image in document field
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 { ... }"?
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