有人可以帮助我如何使用spqr-spring-boot-starter获取架构文件吗?
我在网上寻找解决方案,并发现了这个问题:How to get the generated scheme file .graphqls using SPQR?
new SchemaPrinter(
// Tweak the options accordingly
SchemaPrinter.Options.defaultOptions()
.includeScalarTypes(true)
.includeExtendedScalarTypes(true)
.includeIntrospectionTypes(true)
.includeSchemaDefintion(true)
).print(schema);
但是我不确定应该为架构传递什么?在使用spqr-spring-boot-starter时,我没有编写与GraphQLSchema实例相关的任何内容。
我需要模式文件才能在Postman中启用自动完成功能。如果您对此有所了解,请提供帮助,这将非常有帮助。谢谢!
答案 0 :(得分:0)
根据 spqr 教程,您可能希望在 RestController 类中定义您的 graphQL 模式,您可以将该对象用于 SchemaPrinter。 您可以将其设置为 public 并在代码中的其他地方使用
@Autowired
public GraphQLController(CheckConfigurationDemoResolver checkConfigurationDemoResolver) {
GraphQLSchema schema = new GraphQLSchemaGenerator()
schema = new GraphQLSchemaGenerator()
.withBasePackages("com.acme.mygraphqlproj")
.withOperationsFromSingleton(checkConfigurationDemoResolver)
.generate();
graphQL = GraphQL.newGraphQL(schema).build();
String schemaString = new SchemaPrinter().print(schema);
System.out.println("schemaString = " + schemaString);
}