Heyho,

it seems like there is currently no way to specify schema files by their filename. Instead it is only possible to configure directories.

From GraphqlProperties.java:

private String[] appendSlashIfNecessary(String[] locations) {
            return Arrays.stream(locations)
                .map((location) -> location.endsWith("/") ? location : location + "/")
                .toArray(String[]::new);
        }

Hence this is impossible:

spring.graphql.schema:
    locations:
        # Subgraph's schema
        - classpath:schema/schema.graphqls
        # Federation-specific directives (shared across subgraphs)
        - classpath:schema/federation.graphqls
        # Common types (shared across subgraphs)
        - classpath:schema/Accommodation.graphqls
        - classpath:schema/AccommodationDeal.graphqls

I encountered this obstacle when trying to migrate from DGS to Spring GQL

Comment From: bclozel

Hello @bjoernmayer

Yes that's correct, those are meant to be locations, not fully resolved resources. I'm not sure I understand the use case though. Why point directly to resources and not locations? Are there schema resources in the same location that are not meant to be used? Why?

Comment From: bjoernmayer

Hi @bclozel, thank you for looking into this.

The main reason is Federation.

We are working with subgraphs in a Mono Repository. We have all of our shared types in a shared library. Each subgraph then picks only the types, that it needs and should expose in its schema.

Comment From: bclozel

Spring for GraphQL provides a org.springframework.graphql.execution.GraphQlSource.SchemaResourceBuilder#schemaResources that lets you configure specific schema files.

You can already declare specific resources in your application by contributing a GraphQlSourceBuilderCustomizer bean to your application and add resources manually.

I'll move this issue to Spring Boot to consider a separate configuration property that would let you set additional schema resources on top of scanned ones.

Comment From: jack5505

Hello could you please give me this task for me

Comment From: bclozel

@jack5505 thanks for the proposal but this is targeted for the next minor version and we haven't started working on this yet.