Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ext {
'byte-buddy.version' : '1.18.8',
'commons-text.version' : '1.15.0',
'directory-watcher.version' : '0.19.1',
'gradle-groovy.version' : '4.0.31',
'gradle-groovy.version' : '4.0.32',
'gradle-spock.version' : '2.3-groovy-4.0',
'grails-publish-plugin.version' : '1.0.0-M1',
'jansi.version' : '2.4.2',
Expand Down Expand Up @@ -78,7 +78,9 @@ ext {
'commons-codec.version' : '1.21.0',
'commons-lang3.version' : '3.20.0',
'geb-spock.version' : '8.0.1',
'graphql-java.version' : '24.3',
// graphql-java is managed by spring-boot-dependencies (the SB version always wins),
// so we intentionally do not pin it here. graphql-java-extended-scalars is NOT
// managed by Spring Boot, so it needs an explicit version.
'graphql-java-extended-scalars.version': '24.0',
'groovy.version' : '4.0.32',
'hibernate-groovy-proxy.version': '1.1',
Expand Down Expand Up @@ -118,7 +120,6 @@ ext {
'commons-codec' : "commons-codec:commons-codec:${bomDependencyVersions['commons-codec.version']}",
'commons-lang3' : "org.apache.commons:commons-lang3:${bomDependencyVersions['commons-lang3.version']}",
'geb-spock' : "org.apache.groovy.geb:geb-spock:${bomDependencyVersions['geb-spock.version']}",
'graphql-java' : "com.graphql-java:graphql-java:${bomDependencyVersions['graphql-java.version']}",
'graphql-java-extended-scalars': "com.graphql-java:graphql-java-extended-scalars:${bomDependencyVersions['graphql-java-extended-scalars.version']}",
'groovy' : "org.apache.groovy:groovy:${bomDependencyVersions['groovy.version']}",
'groovy-ant' : "org.apache.groovy:groovy-ant:${bomDependencyVersions['groovy.version']}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ApplicationClassInjector implements GrailsArtefactClassInjector {
static final List<Map<String, String>> CONDITIONAL_EXCLUSIONS = [
[
pluginClass: 'org.grails.plugins.databasemigration.DatabaseMigrationGrailsPlugin',
excludeClass: 'org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration',
excludeClass: 'org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration',
systemProperty: 'grails.autoconfigure.exclude.liquibase'
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ApplicationClassInjectorSpec extends Specification {
where:
expected << [
[
excludeClass: 'org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration',
excludeClass: 'org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration',
pluginClass: 'org.grails.plugins.databasemigration.DatabaseMigrationGrailsPlugin',
systemProperty: 'grails.autoconfigure.exclude.liquibase'
]
Expand Down
7 changes: 5 additions & 2 deletions grails-data-hibernate5/dbmigration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ dependencies {
testImplementation project(':grails-testing-support-web')
testImplementation 'com.h2database:h2'

// Liquibase uses JUL for logging -> redirect it to SLF4J to reliably capture its output
// Liquibase uses JUL for logging -> redirect it to SLF4J to reliably capture its output.
// Spring Boot's starter (transitively via spring-boot-starter-tomcat) already supplies
// Logback as the SLF4J binding; adding slf4j-simple here would cause two competing
// bindings and Spring Boot's LogbackLoggingSystem aborts context startup when that
// happens. See https://www.slf4j.org/codes.html#multiple_bindings
testRuntimeOnly 'org.slf4j:jul-to-slf4j'
testRuntimeOnly 'org.slf4j:slf4j-simple'
}

tasks.named('test', Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void applyToMainClass(GroovyClassLoader loader, GroovyCompilerConfigurati
ClassNode applicationClassNode = new ClassNode("Application", Modifier.PUBLIC, ClassHelper.make("grails.boot.config.GrailsAutoConfiguration"));
AnnotationNode enableAutoAnnotation = new AnnotationNode(ENABLE_AUTO_CONFIGURATION_CLASS_NODE);
try {
enableAutoAnnotation.addMember("exclude", new ClassExpression(ClassHelper.make("org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration")));
enableAutoAnnotation.addMember("exclude", new ClassExpression(ClassHelper.make("org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration")));
} catch (Throwable e) {
// ignore
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ dependencies {

testImplementation 'org.apache.grails:grails-testing-support-datamapping'
testImplementation 'org.apache.grails:grails-testing-support-web'

// Auto-start a MongoDB testcontainer before integration tests (overrides the
// localhost:27017 host in application.yml via grails.mongodb.host system property).
testImplementation 'org.apache.grails.testing:grails-testing-support-mongodb'
}

apply {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
<configuration>

<conversionRule conversionWord="clr" class="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" class="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex</pattern>
</encoder>
</appender>

<root level="error">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ package myapp

import grails.testing.mixin.integration.Integration
import org.bson.types.ObjectId
import org.grails.datastore.gorm.GormEnhancer
import org.grails.datastore.mapping.mongo.MongoDatastore
import org.grails.gorm.graphql.plugin.testing.GraphQLSpec

import spock.lang.Specification

@Integration
class BarIntegrationSpec implements GraphQLSpec {
class BarIntegrationSpec extends Specification implements GraphQLSpec {

void "test a bar can be created"() {
when:
Expand All @@ -43,8 +44,10 @@ class BarIntegrationSpec implements GraphQLSpec {
""")
Map obj = resp.body().data.barCreate

then:
then: 'bar is created in the Mongo datastore with a valid ObjectId'
new ObjectId((String) obj.id)
Bar.withNewSession { session -> session.datastore instanceof MongoDatastore }
// GORM no longer surfaces `datastore` as a property on the Mongo session;
// reach it through GormEnhancer's static API instead.
GormEnhancer.findStaticApi(Bar).datastore instanceof MongoDatastore
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
package myapp

import grails.testing.mixin.integration.Integration
import org.grails.datastore.gorm.GormEnhancer
import org.grails.gorm.graphql.plugin.testing.GraphQLSpec
import org.grails.orm.hibernate.HibernateDatastore
import spock.lang.Specification

@Integration
class FooIntegrationSpec implements GraphQLSpec {
class FooIntegrationSpec extends Specification implements GraphQLSpec {

void "test a foo can be created"() {
when:
Expand All @@ -41,8 +43,10 @@ class FooIntegrationSpec implements GraphQLSpec {
""")
Map obj = resp.body().data.fooCreate

then:
then: 'foo is created in the Hibernate datastore'
obj.id == 1
Foo.withNewSession { session -> session.datastore instanceof HibernateDatastore }
// GORM no longer surfaces `datastore` as a property on the Hibernate
// SessionImpl; reach it through GormEnhancer's static API instead.
GormEnhancer.findStaticApi(Foo).datastore instanceof HibernateDatastore
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MyGraphQLCustomizer extends GraphQLPostProcessor {
@Override
void doWith(GraphQLTypeManager typeManager) {
typeManager.registerType(ObjectId, GraphQLScalarType.newScalar()
.name("ObjectId").description("Hex representation of a Mongo object id").coercing(new Coercing<ObjectId, ObjectId>() {
.name("ObjectId").description("Hex representation of a Mongo object id").coercing(new Coercing<ObjectId, String>() {

protected Optional<ObjectId> convert(Object input) {
if (input instanceof ObjectId) {
Expand All @@ -45,9 +45,13 @@ class MyGraphQLCustomizer extends GraphQLPostProcessor {
}
}

// graphql-java 25 no longer invokes toString on returned scalar values during
// serialization; the Coercing must produce the wire representation itself.
// Returning a String (hex) ensures the GraphQL response carries the 24-char
// hex form rather than ObjectId's structured property bag.
@Override
ObjectId serialize(Object input) {
convert(input).orElseThrow({
String serialize(Object input) {
convert(input).map { it.toString() }.orElseThrow({
throw new CoercingSerializeException("Could not convert ${input.class.name} to an ObjectId")
})
}
Expand Down
7 changes: 7 additions & 0 deletions grails-test-examples/graphql/spring-boot-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'

// Spring Boot 4 moved HibernateJpaAutoConfiguration to the spring-boot-hibernate module.
// It must be on the runtime classpath: GORM's HibernateGormAutoConfiguration
// declares @AutoConfigureBefore([HibernateJpaAutoConfiguration]), and DemoApplication
// references the class in @EnableAutoConfiguration(exclude = ...). Spring Boot's actual
// JPA auto-configuration is then suppressed by that exclusion so GORM owns Hibernate.
implementation 'org.springframework.boot:spring-boot-hibernate'

// GORM + Hibernate 5 (Jakarta variant), configured via GORM's Spring Boot auto-config
// (registers HibernateDatastore, dataSource, transactionManager as Spring beans).
implementation 'org.apache.grails:grails-data-hibernate5-spring-boot'
Expand Down
Loading