示例片段:
rs191919:~/workspace/sample_app (elastic-again) $ wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.7.0.deb
--2016-03-11 17:21:12-- https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.7.0.deb
Resolving download.elasticsearch.org (download.elasticsearch.org)... 23.21.221.132, 23.21.209.176, 23.23.251.246, ...
Connecting to download.elasticsearch.org (download.elasticsearch.org)|23.21.221.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27320700 (26M) [application/x-debian-package]
Saving to: ‘elasticsearch-1.7.0.deb.1’
100%[==========================================================================================================>] 27,320,700 22.5MB/s in 1.2s
2016-03-11 17:21:14 (22.5 MB/s) - ‘elasticsearch-1.7.0.deb.1’ saved [27320700/27320700]
rs191919:~/workspace/sample_app (elastic-again) $ sudo dpkg -i elasticsearch-1.7.0.deb
Selecting previously unselected package elasticsearch.
(Reading database ... 125961 files and directories currently installed.)
Preparing to unpack elasticsearch-1.7.0.deb ...
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Unpacking elasticsearch (1.7.0) ...
Setting up elasticsearch (1.7.0) ...
Processing triggers for ureadahead (0.100.0-16) ...
rs191919:~/workspace/sample_app (elastic-again) $ sudo update-rc.d elasticsearch defaults 95 10
System start/stop links for /etc/init.d/elasticsearch already exist.
rs191919:~/workspace/sample_app (elastic-again) $ sudo /etc/init.d/elasticsearch start
* Starting Elasticsearch Server sysctl: setting key "vm.max_map_count": Read-only file system
rs191919:~/workspace/sample_app (elastic-again) $ curl http://localhost:9200
curl: (7) Failed to connect to localhost port 9200: Connection refused
rs191919:~/workspace/sample_app (elastic-again) $
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'})
变量作为字符串传递给GraphQL服务器。
如何将这些变量中的任何一个传递给Relay的setVariables而不将它们作为字符串发送?
答案 0 :(得分:3)
您现在可以将枚举变量用作字符串。
EventsConnectionOrder
是一个枚举)query($orderBy: [EventsConnectionOrder]){
viewer {
events(first:1 orderBy: $orderBy) {
edges {
node {
id
}
}
}
}
}
{
"orderBy": "dateASC"
}