Upwork的 GraphQL API在非空字段amount: Money! 上返回了null,导致整个查询失败
我在接入Upwork的 GraphQL API时,在进行工作搜索查询时遇到了一个运行时的GraphQL错误。
The query is against `marketplaceJobPostingsSearch`, and I request the `amount` field like this:
const SEARCH_JOBS_QUERY = `
query(
$marketPlaceJobFilter: MarketplaceJobPostingsSearchFilter,
$searchType: MarketplaceJobPostingSearchType,
$sortAttributes: [MarketplaceJobPostingSearchSortAttribute]
) {
marketplaceJobPostingsSearch(
marketPlaceJobFilter: $marketPlaceJobFilter,
searchType: $searchType,
sortAttributes: $sortAttributes
) {
totalCount
edges
{
node {
id
title
createdDateTime
description
duration
durationLabel
engagement
ciphertext
amount {
rawValue
currency
}
skills {
name
prettyName
}
hourlyBudgetMin{
rawValue
currency
displayValue
}
hourlyBudgetMax{
rawValue
currency
displayValue
}
experienceLevel
category
subcategory
client {
totalSpent {
rawValue
currency
}
totalHires
totalPostedJobs
totalReviews
companyName
verificationStatus
location {
country
}
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
`;
根据架构,该字段是不可为空的字段:
amount: Money!
然而,某些针对 amount 的搜索结果返回 null,GraphQL会抛出类似如下的错误:
The field at path '/marketplaceJobPostingsSearch/edges[26]/node/amount'
was declared as a non null type, but the code involved in retrieving
data has wrongly returned a null value.
由于GraphQL的空值冒泡机制,响应中包含一个 errors 数组,导致我的同步现在失败。
在我的应用中,amount 已经被视为可选项:
amount: UpworkJobAmount | null;
我的问题是:
- Upwork是否还暴露了一个用于市场搜索结果的可为空的预算字段?
- 在这种情况下,GraphQL客户端应否容忍部分
errors的响应? - 还有人遇到Upwork GraphQL API的非空约束被违反的情况吗?
任何指导或最佳实践都将不胜感激。
解决方案
请 联系支持团队 并提供详细信息。最好提供作为响应头一部分的跟踪ID(trace ID)。
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。