目前,我正在学习使用playframework的Sangria-graphql,并且正在学习here的教程。我理解Executor Executor.execute(schema, query, new ProductRepo),它接受模式、查询和上下文。另一方面,当我通过演示示例代码时,我使用了以下Executor,其中还提供了operationName和变量。例如,
Executor.execute(SchemaDefinition.StarWarsSchema, queryAst, new CharacterRepo,
operationName = operation,
variables = variables getOrElse Json.obj(),
deferredResolver = DeferredResolver.fetchers(SchemaDefinition.characters),
maxQueryDepth = Some(10))
.map(Ok(_))我还不是很明白。如果变量意味着我们的查询的论点,那么查询它自己包含查询参数,比如下面的查询中的id。
{
human(id: "1000") {
name
height(unit: FOOT)
}
}此外,在这种情况下,operationName为什么以及如何受益?那么,有没有人可以解释一下它,以及客户端如何为这些operationName和变量提供查询请求。
发布于 2017-01-25 20:47:47
在本例中,变量的含义不同于参数(比如您的id: "1000")。
看一看documentation of variables in GraphQL。
operationName也是如此:documentation for this
https://stackoverflow.com/questions/41851366
复制相似问题