【问题标题】:Could not find any GraphQL schema file under configured locations - SpringBoot , GraphQL在配置的位置下找不到任何 GraphQL 模式文件 - SpringBoot,GraphQL
【发布时间】:2022-02-25 18:11:59
【问题描述】:

我正在尝试使用 GraphQL 在 spring-boot 上运行空项目,但出现以下错误。

2022-01-03 12:33:11.440 ERROR 12944 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Could not find any GraphQL schema file under configured locations.

Action:

Check that the following locations contain schema files: 
- '' (classpath:graphql/**/)

依赖关系:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-graphql</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

方案:/resources/schema.graphqls:

type Query {
  bookById(id: ID): Book
}

type Book {
  id: ID
  name: String
  pageCount: Int
  author: Author
}

type Author {
  id: ID
  firstName: String
  lastName: String
}

有没有配置错误?

【问题讨论】:

  • 错误消息告诉你 Spring GraphQL 在 graphql/ 目录下的类路径中查找模式文件。将架构文件移动到 src/main/resources/graphql/ 目录。

标签: java spring-boot graphql


【解决方案1】:

将您的文件重命名为 schema.graphql 文件重命名为 schema.graphqls

【讨论】:

    猜你喜欢
    • 2021-12-14
    • 2020-03-13
    • 2021-04-10
    • 2019-07-17
    • 2019-01-10
    • 2021-01-02
    • 2022-12-14
    • 2020-11-24
    • 2018-12-25
    相关资源
    最近更新 更多