所以我最近才开始使用graphql(准确地说是上周)。我得到了能够使用“where”参数过滤查询的概念,但我注意到,当我尝试从深层嵌套查询中获取对象时,它变得有点不可能。所以说我有'domestic_worker_nextofkin'查询应该得到全名,mobile_phone1和'archived'_is_null等于true的关系,如下所示:
domestic_workers_nextofkin(where: {archived:{_is_null: true}}){
full_name
mobile_phone1
domestic_workers_relationships{
relationship
}
}
}
上面的查询完成了它的预期工作并获取了全名、mobile_phone1 和关系。
但我目前的问题是,当这个查询被深度嵌套时,如下所示(带星号的代码):
query User($userId: Int) {
domestic_workers_news{
title
date_created
summary
url
}
users_user(where: {id: {_eq: $userId}}) {
domestic_workers_pictures(order_by: {id: desc}, limit: 1) {
id
}
id
password
username
first_name
last_name
email
gender
birth_date
mobile_phone1
mobile_phone2
home_address_street
home_address_town
home_address_lga
home_address_state
home_address_country
home_address_postal_code
job_title
workplace
verified
agreed_terms
date_joined
last_modified
domestic_workers_workers {
domestic_workers_pictures(order_by: {id: desc}, limit: 1) {
id
}
id
first_name
last_name
other_name
email
mobile_phone1
mobile_phone2
home_town
home_state
service
birth_date
gender
date_created
current_employer_id
domestic_workers_relationships{
id
payment
payment_currency
start_date
relationship
domestic_workers_agent {
full_name
mobile_phone1
domestic_workers_relationships{
relationship
}
domestic_workers_pictures(order_by: {id: desc}, limit: 1) {
id
}
}
**domestic_workers_nextofkin (where: {archived:{_is_null: true}}) {
full_name
mobile_phone1
domestic_workers_relationships{
relationship
}
}
}**
domestic_workers_reviews {
id
score
summary
date_created
users_user {
first_name
last_name
domestic_workers_pictures(order_by: {id: desc}, limit: 1) {
id
}
}
}
employerRelationships: domestic_workers_relationships(order_by: {id: desc}, limit: 1, where: {relationship: {_eq: "Employer"}}) {
end_date
relationship
}
}
}
}
它显示“where”参数以红色突出显示,这可能意味着“where”参数不应该放在那里,这对我来说似乎相当混乱。谁能解释为什么会发生这种情况并向我展示一个解决方法来完成我正在尝试执行的任务?谢谢。