如何在Graphql上定义动态变量?
所以,我正在使用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
应返回不同的内容。
我刚刚通过更改result = Client.query Query
解决了我的问题result = Client.query Query
===> result = Client.query Query, variables: { message: "hello" }