【发布时间】:2021-05-04 14:10:38
【问题描述】:
我想创建一个客户端来使用 GraphQL 端点。
我试过GraphQL Java提供的示例代码,看起来 像这样:
GraphQLObjectType fooType = newObject()
.name("Foo")
.field(newFieldDefinition()
.name("bar")
.type(GraphQLString))
.build();
GraphQLSchema schema = GraphQLSchema.newSchema()
.query(fooType)
.build();
GraphQL graphQL = GraphQL.newGraphQL(schema)
.build();
ExecutionInput executionInput = ExecutionInput.newExecutionInput()
.query("query { hero { name } }")
.build();
ExecutionResult executionResult = graphQL.execute(executionInput);
Object data = executionResult.getData();
List<GraphQLError> errors = executionResult.getErrors();
我不知道这是否是最好的方法。我使用 AWS AppSync 作为 GraphQL 服务器。如何更新我的代码,以便它引用 AWS 端点?
【问题讨论】:
标签: java graphql aws-appsync