craftql
craftql copied to clipboard
Craft Color FIelds returns an error
I'm trying to get a color fields' HEX code but I got an error below.
{
"error": "String cannot represent non scalar value: instance of craft\\fields\\data\\ColorData"
}
My code is something like this and the 'bgColor' in slides block is the color fields. Color fields' type returns string but I can't get return the HEX code somehow.
{
entries(section: [screensaver]) {
... on Screensaver {
id
title
slides {
... on SlidesBlock {
__typename
bgColor
}
}
}
}
}
Cheers, Masato
I'm running in to the same issue, I believe the Color field should't be a string but use the following structure: https://docs.craftcms.com/api/v3/craft-fields-data-colordata.html#public-properties
so when using the code above it would be like this:
{
entries(section: [screensaver]) {
... on Screensaver {
id
title
slides {
... on SlidesBlock {
__typename
bgColor {
hex
}
}
}
}
}
}
I've opened a PR: https://github.com/markhuot/craftql/pull/141 that fixes the bug, but is has no support for color channels yet
FYI, in the Schema explorer it still shows these fields as coming back string.
They should have a subselection of:
FIELD {
hex
rgb
luma
r
g
b
}
I spent a while trying to troubleshoot this error because the schema explorer shows it as type string.