I'm getting this error:
message: 'The following path cannot be queried: vowelArray.vowelSound'
Here's my query:
const query = {
"vowelArray.vowelSound.value.slug": {
equals: targetWord.vowelArray[0].vowelSound.value.slug,
}
}
I have
access: {read: () => true,},
set at both the field (for troubleshooting) and collection level for the "vowel" relationship I have set up and
read: () => true
at the collection level for the "word" collection.
I see it come through in the response:
"vowelArray": [
{
"syllableNumber": 1,
"vowelSound": {
"value": {
"id": "64db67db910ca53cb73d30af",
"vowel": "Long "e" like "fleece"",
"slug": "long-e",
"createdAt": "2023-08-15T11:56:11.366Z",
"updatedAt": "2023-08-15T11:56:11.366Z"
},
"relationTo": "vowels"
},
"id": "64dbee9ce8d80d342199131b"
}
I am able to access the relationship using dot notation:
word.docs[0].vowelArray[0].vowelSound.value.slug
but when I run the query, I get the error.
Any insight here?
Changing from “vowelArray.vowelSound” to vowelArray: {vowelSound: …} helped but the query returns all records instead of my desired result. So now I’m trying to figure that out
Okay, so this still isn't working. I can't access relationship data from my query. I tried it this way:
?where[vowelArray.vowelSound.value.id][equals]=64db67db910ca53cb73d30af
(source:
https://payloadcms.com/docs/fields/relationship#how-the-data-is-saved) for example and am getting the same "can't query path." I can use fetch on the front end to query both the vowel and word collections no problem, so it doesn't seem to be an access control issue. Would love some help here
vowelSound
is a key of a document object, not a value in the
vowelArray
array. Try changing
vowelArray.vowelSound
to
vowelArray[0].vowelSound
.
can you paste in your vowelArray field config? Sounds like you might want to use a relationship field with
hasMany
instead of an array field type.
@281120856527077378
thanks for dropping in! I think my problem was not understanding how the query should be structured. I just got this working before your messages came through. What I did was change the relationship from "Has One - Polymorphic" to just Has One and then changed my query to
`const query = {
"vowelArray.vowelSound": {
equals: targetWord.vowelArray[0].vowelSound.id
},
word: {
not_equals: targetWord.word,
not_in: targetWord.homophones.homophone,
}
}
- I'm sure I could have gotten this working as a polymorphic relationship not that I've figured out that I don't have to drill all the way down to the value I want like
"vowelArray.vowelSound.value.slug"
in my above example.
I'm going to confirm this is working as intended before marking as solved.
Oh wow I literally just asked this same question
https://discord.com/channels/967097582721572934/1141446134859038811What is your suggestion for querying polymorphics?
Star
Discord
online
Get dedicated engineering support directly from the Payload team.