Replies: 3 comments
-
Here's my
The error arises once I implement a data fetcher for the @DgsComponent
public class TestDataFetcher {
@DgsQuery(field = DgsConstants.QUERY.Tests)
public TestConnection tests() {
return null;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
It’s a known issue with the schema validation in spring graphql related to
connections. While that issue exists, you can disable the validation with a
property.
…On Mon, May 13, 2024 at 10:56 AM GregLyons ***@***.***> wrote:
Here's my build.gradle and my schema in a minimal example:
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.5'
id 'io.spring.dependency-management' version '1.1.4'
id "com.netflix.dgs.codegen" version "6.1.10"
}
group = 'org.example'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '21'
}
repositories {
mavenCentral()
}
dependencyManagement {
imports {
mavenBom("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:latest.release")
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation "com.netflix.graphql.dgs:graphql-dgs-spring-graphql-starter"
}
tasks.named('test') {
useJUnitPlatform()
}
generateJava{
schemaPaths = ["${projectDir}/src/main/resources/schema"] // List of directories containing schema files
packageName = 'com.example.graphqltypes' // The package name to use to generate sources
generateClient = true // Enable generating the type safe query API
}
interface Node {
id: ID!
}
interface Edge {
cursor: String!
node: Node!
}
type PageInfo {
endCursor: String
hasNextPage: Boolean!
startCursor: String
hasPreviousPage: Boolean!
}
interface Connection {
pageInfo: PageInfo!
edges: [Edge!]!
}
type TestNode implements Node {
id: ID!
}
type TestEdge implements Edge {
cursor: String!
node: TestNode!
}
type TestConnection implements Connection {
pageInfo: PageInfo!
edges: [TestEdge!]!
}
type Query {
tests: TestConnection!
}
type Test {
useless: String
}
—
Reply to this email directly, view it on GitHub
<#1907 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA2XLHXXTBHYZHWOMRJPM3ZCAMUXAVCNFSM6AAAAABHTJZI42VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TIMJSGI3DS>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you, I was able to find the property:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I recently tried to update the DGS dependency in our project, and I'm met with the following error whenever I try to run the application:
What's happening is that
org.springframework.graphql.execution.SchemaMappingInspector#getPaginatedType
from the Spring GraphQL package is trying to enforce a specific naming convention on my schema:Basically, if you have a type called
TestConnection
, there must be a type calledTest
in the schema. Otherwise, this validation will prevent the application from starting.I'm not aware of any spec that this behavior is following. The Relay connection spec, which is the only spec I've seen for pagination with connections, only necessitates that the connection types themselves end with
Connection
; it doesn't require anything on the naming of the edge or node types. In our project, we suffix our node types withNode
, for example.What options do we have to update? Given that the validation holds even if
TestNode
is aninterface
, we cannot change the name of aninterface
likeTestNode
since that would be a breaking change to our API consumers trying to query theinterface
. The least disruptive change I can think of is to make a dummy type with the expected name:This gets rid of the error, but isn't so satisfactory. Perhaps there's a way to remove it from introspection? At least then it wouldn't be visible to API consumers.
I understand that this issue is caused by Spring GraphQL rather than the DGS Framework itself, but given that DGS is moving towards integration with Spring GraphQL, I'd like to know if DGS has any recommendations that would make this adoption easier. I personally would suggest to Spring GraphQL that they either give the option to opt-out of the validation altogether, and/or give the option to have a consistent suffix on the node types, especially since I'm not aware of any spec that requires this naming convention that they're enforcing. Is there anyway to make it so that we could at least configure the
graphql-dgs-spring-graphql-starter
to prevent this behavior?Beta Was this translation helpful? Give feedback.
All reactions