所以,我正在使用ruby on rails。这是我的代码:
require 'graphql/client'
require 'graphql/client/http'
HTTP = GraphQL::Client::HTTP.new("Graph-API-Web-Site")
Schema = GraphQL::Client.load_schema(HTTP)
Client = GraphQL::Client.new(schema: Schema,execute: HTTP)
Query = Client.parse <<-'GRAPHQL'
query($message: String = "Hello") {
stickers(query: $message, first: 21, after: "") {
edges {
node {
fileUrl(fullWatermarked: true)
}
}
}
}
GRAPHQL
result = Client.query Query
puts result.data.inspect
如何为贴纸{query: .....}
区域赋予特定价值?我想用程序运行更改消息的值。例如,当消息发生变化时,Client.query
应返回不同的内容。
答案 0 :(得分:0)
我刚刚通过更改result = Client.query Query
===&gt;解决了我的问题result = Client.query Query, variables: { message: "hello" }