我最近開始使用graphql
,發現它非常有趣。由於我的rest
應用大部分都在java
,因此我決定使用由graphql-java
團隊提供的spring boot starter項目進行快速設置。它配備了graph-iql
autoconf彈簧設置,這使得查詢/graphql
端點更容易。春季啓動啓動器graphql不工作
在IDEA項目設置上花費了好幾個小時後,我能夠運行graphql-sample-app。但我認爲我的servlet仍未啓用,並且只有graphiql
端點正在運行,因爲默認查詢返回404
。
這是application.yml
:
spring:
application:
name: graphql-todo-app
server:
port: 9000
graphql:
spring-graphql-common:
clientMutationIdName: clientMutationId
injectClientMutationId: true
allowEmptyClientMutationId: false
mutationInputArgumentName: input
outputObjectNamePrefix: Payload
inputObjectNamePrefix: Input
schemaMutationObjectName: Mutation
servlet:
mapping: /graphql
enabled: true
corsEnabled: true
graphiql:
mapping: /graphiql
enabled: true
這是我的build.gradle
文件看起來像:
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
maven { url 'http://repo.spring.io/plugins-release' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE")
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6"
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
repositories {
jcenter()
mavenCentral()
}
dependencies{
// compile(project(":graphql-spring-boot-starter"))
// compile(project(":graphiql-spring-boot-starter"))
compile 'com.graphql-java:graphql-spring-boot-starter:3.6.0'
// to embed GraphiQL tool
compile 'com.graphql-java:graphiql-spring-boot-starter:3.6.0'
compile "com.embedler.moon.graphql:spring-graphql-common:$LIB_SPRING_GRAPHQL_COMMON_VER"
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
jar.enabled = true
uploadArchives.enabled = false
bintrayUpload.enabled = false
運行gradle build
後,我跑從終端生成的jar
文件。這是我得到的本地主機:
這是一個有點很難說這是怎麼回事,而不完整的代碼,你會介意創建一個示例項目並將其扔到github上嗎? – apottere