如何在 Graphql 上定义动态变量? [英] How to define dynamic variables on Graphql?
本文介绍了如何在 Graphql 上定义动态变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以,我正在研究 ruby on rails.这是我的代码:
So, I am working on ruby on rails. This is my code:
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
应该返回不同的东西.
How can I give specific value to stickers {query: .....}
area? I want to change the value of message with program runs. For example when the message changes the Client.query
should return something different.
推荐答案
我刚刚通过更改 result = Client.query Query
===> result = Client.query 解决了我的问题查询,变量:{ message: "hello" }
I have just solved my problem via changing result = Client.query Query
===> result = Client.query Query, variables: { message: "hello" }
这篇关于如何在 Graphql 上定义动态变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文