简体   繁体   English

spring boot starter graphql无法正常工作

[英]spring boot starter graphql not working

I recently started working with graphql and found it very intriguing. 我最近开始使用graphql ,发现它非常有趣。 Since most of my rest apps were in java , I decided to do a quick setup using the provided spring boot starter project by the graphql-java team. 由于我的大多数rest应用程序都是使用java ,我决定使用graphql-java团队提供的spring boot starter项目进行快速设置。 It comes with graph-iql autoconf spring setup, which makes it easier to query /graphql endpoint. 它带有graph-iql autoconf spring设置,可以更容易地查询/graphql端点。

After spending a few good hours on the project setup in IDEA, I was able to run the graphql-sample-app . 在IDEA的项目设置上花了几个小时后,我能够运行graphql-sample-app But I think my servlet is still not enabled, and only the graphiql endpoint is running, as the default query is returning 404 . 但我认为我的servlet仍然没有启用,只有graphiql端点正在运行,因为默认查询返回404

This is application.yml : 这是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

This is what my build.gradle file looks like: 这是我的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

After running gradle build , I run the generated jar file from the terminal. 运行gradle build ,我从终端运行生成的jar文件。 This is what I get on localhost: 这是我在localhost上得到的:

在此输入图像描述

I had the same issue using Spring boot 2.0.0 (M6). 我使用Spring boot 2.0.0(M6)遇到了同样的问题。 Switching back to 1.5.8.RELEASE solved the problem. 切换回1.5.8.RELEASE解决了这个问题。 They're working on the issue, it will be released as soon as there is a non milestone release for Spring boot 2.x 他们正在解决这个问题,一旦Spring boot 2.x出现非里程碑版本,它就会被释放

https://github.com/graphql-java/graphql-spring-boot/issues/40 https://github.com/graphql-java/graphql-spring-boot/issues/40

https://github.com/graphql-java/graphql-spring-boot/pull/36 https://github.com/graphql-java/graphql-spring-boot/pull/36

更改为版本1.5.9.RELEASE的spring-boot-starter-stop,它对我有用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 graphql-spring-boot-starter 应用程序只有 websockets - graphql-spring-boot-starter Application with only websockets 在 spring 启动 graphql 启动器中等效的 Kickstarter 类型字典 - Kickstarter type dictionary equivalent in spring boot graphql starter spring 引导包含 com.graphql-java 和 graphql-java-spring-boot-starter-webmvc - spring boot containing com.graphql-java and graphql-java-spring-boot-starter-webmvc spring boot starter security post方法不起作用 - spring boot starter security post methods not working 如何使用 spring-spqr graphql-spqr-spring-boot-starter graphQL 的注释创建片段 - how to create fragments using Annotations of spring-spqr graphql-spqr-spring-boot-starter graphQL 使用 graphql-java-tools 和 graphql-spring-boot-starter 进行错误处理 - Error handling with graphql-java-tools and graphql-spring-boot-starter Spring 引导启动器 - RestTemplate - Spring Boot starter - RestTemplate 我们如何从 GraphQL 的 RequestContextHolder 中获取 GraphQL 的 HttpServletRequest(DefaultGlobalContext)(使用 graphql-spqr-spring-boot-starter)? - How can we get HttpServletRequest(DefaultGlobalContext) for GraphQL from RequestContextHolder for GraphQL (using graphql-spqr-spring-boot-starter)? Spring 带有 spring-boot-starter-validation 的引导验证不适用于 Spring 引导版本 2.4.4 - Spring Boot Validation with spring-boot-starter-validation is not working for Spring boot version 2.4.4 异常处理程序不适用于`spring-boot-starter-data-rest` - Exception Handler Not Working with `spring-boot-starter-data-rest`
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM