我无法让 GraphQL 服务器使用 SpringBoot 工作。
事实上,playground 正在网上显示,但它并没有让我做任何事情。这是我从 Graphql 游乐场得到的错误。
"error": "Response not successful: Received status code 404"
右侧用于查询和解析器的游乐场文档正在无限加载。
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.codehaus.groovy:groovy'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
implementation 'com.graphql-java-kickstart:graphql-java-tools:12.0.1'
implementation 'com.graphql-java-kickstart:playground-spring-boot-starter:5.10.0'
}
// Application.java
@SpringBootApplication
class Application {
static void main(String[] args) {
SpringApplication.run(Application, args)
}
}
// resolver/BankAccountResolver.java
@Slf4j
@Component
class BankAccountResolver implements GraphQLQueryResolver {
void bankAccount(UUID id) {
log.info "Retrieving bank account: $id"
}
}
// domain/BankAccount.java
class BankAccount {
UUID id
String name
Currency currency
}
// query.graphqls
type Query {
bankAccount(id: ID): BankAccount
}
// bankAccount.graphqls
type BankAccount {
id: ID!
name: String!
currency: Currency!
}