gpt4 book ai didi

javascript - 如何将中继变量设置为枚举值?

转载 作者:行者123 更新时间:2023-11-29 19:15:04 24 4
gpt4 key购买 nike

示例片段:

fragments: {
viewer: () => Relay.QL`
fragment on Viewer {
people(first: $limit orderBy: $orderBy) {
count
edges {
node {
id,
${PersonListItem.getFragment('person')},
},
},
}
}
`,
},

orderBy 参数接受以下枚举值:firstNameASC/firstNameDESC/lastNameASC/lastNameDESC

执行 this.setVariables({orderBy: 'firstName'}) 时,orderBy 变量作为字符串传递给 GraphQL 服务器。

如何将这些变量中的任何一个传递到 Relay 的 setVariables 中而不将它们作为字符串发送?

最佳答案

您现在可以将枚举变量用作字符串。

例子

查询(EventsConnectionOrder 是一个枚举)

query($orderBy: [EventsConnectionOrder]){
viewer {
events(first:1 orderBy: $orderBy) {
edges {
node {
id
}
}
}
}
}

变量

{
"orderBy": "dateASC"
}

关于javascript - 如何将中继变量设置为枚举值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35946313/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com