Skip to content

Commit

Permalink
Merge pull request #6 from MEITREX/add-on-demand-directive
Browse files Browse the repository at this point in the history
Add on demand directive
  • Loading branch information
PaulBredl authored Apr 29, 2024
2 parents 30969e5 + 77b241b commit 1aac6cf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
java-version: '21'
distribution: 'temurin'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2
uses: gradle/wrapper-validation-action@v3
- name: Run chmod to make gradlew executable
run: chmod +x gradlew
- name: Execute tests
Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id 'org.springframework.boot' version '3.+'
id 'io.spring.dependency-management' version '1.+'
id "io.github.kobylynskyi.graphql.codegen" version "5.+"
id "org.sonarqube" version "4.+"
id "org.sonarqube" version "5.+"
id "jacoco"
}

Expand Down Expand Up @@ -48,6 +48,7 @@ graphqlCodegen {
]
generateEqualsAndHashCode = true
generateToString = true
fieldsWithResolvers = ["@OnDemand"]
}

// Automatically generate GraphQL code on project build:
Expand Down Expand Up @@ -80,7 +81,7 @@ dependencies {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation "org.mockito:mockito-core:3.+"
testImplementation "org.mockito:mockito-core:5.+"
testImplementation 'org.hamcrest:hamcrest:2.+'
}

Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/graphql/directives.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ directive @Positive(message : String = "graphql.validation.Positive.message") on
directive @PositiveOrZero(message : String = "graphql.validation.PositiveOrZero.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
directive @Range(min : Int = 0, max : Int = 2147483647, message : String = "graphql.validation.Range.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
directive @Size(min : Int = 0, max : Int = 2147483647, message : String = "graphql.validation.Size.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
directive @ContainerSize(min : Int = 0, max : Int = 2147483647, message : String = "graphql.validation.ContainerSize.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
directive @ContainerSize(min : Int = 0, max : Int = 2147483647, message : String = "graphql.validation.ContainerSize.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION

"""
The @OnDemand directive is used to mark fields that are only internally resolved when requested.
Implementation Note: This will cause the code generator to omit the field from the generated DTOs.
"""
directive @OnDemand on FIELD_DEFINITION

0 comments on commit 1aac6cf

Please sign in to comment.