gpt4 book ai didi

Python GraphQL Client - 传递变量时意外的标点符号

转载 作者:行者123 更新时间:2023-12-05 06:03:47 26 4
gpt4 key购买 nike

代码:

contract="0xdAC17F958D2ee523a2206206994597C13D831ec7"

query = """
($contract: Int!) {
token(id:$contract){
name
symbol
decimals
derivedETH
tradeVolumeUSD
totalLiquidity
}
}
"""

variables = {
"contract": contract
}

data = client.execute(query=query, variables=variables)

错误:

{'errors': [{'locations': [{'column': 1, 'line': 2}], 'message': 'Unexpected `([Punctuator]`\nExpected `{`, `query`, `mutation`, `subscription` or `fragment`'}]}

我尝试了多种重新格式化的方法,但无法消除此错误!帮助!

最佳答案

您的 GraphQL 查询必须以 query 开头:

query($someVar: String!) {
someQuery(someArg: $someVar) {
...
}
}

关于Python GraphQL Client - 传递变量时意外的标点符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66585727/

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