Mat*_*w P 3 graphql apollo-server
您可以使用GraphQL架构语言将数字用作GraphQL架构中的键吗?即(这是一个小片段...)
type tax_code_allocation_country_KOR_states {
"11": tax_code_allocation_state_tax_query
"26": tax_code_allocation_state_tax_query
"27": tax_code_allocation_state_tax_query
}
Run Code Online (Sandbox Code Playgroud)
或以下内容,我意识到这是错误的JSON:
type tax_code_allocation_country_KOR_states {
11: tax_code_allocation_state_tax_query
26: tax_code_allocation_state_tax_query
27: tax_code_allocation_state_tax_query
}
Run Code Online (Sandbox Code Playgroud)
不,这是规范所禁止的。可以在数字前加上下划线:
type tax_code_allocation_country_KOR_states {
_11: tax_code_allocation_state_tax_query
_26: tax_code_allocation_state_tax_query
_27: tax_code_allocation_state_tax_query
}
Run Code Online (Sandbox Code Playgroud)
或者或者根本不在类型级别上执行此操作,而是映射查询或仅运行过滤器查询:
type tax_code_allocation_country_KOR_states {
tax(code: 11): tax_code_allocation_state_tax_query
tax(codes: [11, 26, 27]): [tax_code_allocation_state_tax_query]
}
# query subselection
{ _11: tax(code: 11), _26: tax(code: 26), _27: tax(code: 27) }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
418 次 |
| 最近记录: |