Skip to content

Commit

Permalink
Merge pull request #1022 from setchy/feature/ids-scalars
Browse files Browse the repository at this point in the history
feature: add UUID Scalar
  • Loading branch information
berngp committed May 2, 2022
2 parents f43d38c + 3f3a9d4 commit 2791d9d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Expand Up @@ -135,6 +135,24 @@ open class DgsExtendedScalarsAutoConfiguration {
}
}

@ConditionalOnProperty(
prefix = "dgs.graphql.extensions.scalars.ids",
name = ["enabled"],
havingValue = "true",
matchIfMissing = true
)
@Configuration(proxyBeanMethods = false)
open class IDsExtendedScalarsAutoConfiguration {
@Bean
open fun idsExtendedScalarsRegistrar(): ExtendedScalarRegistrar {
return object : AbstractExtendedScalarRegistrar() {
override fun getScalars(): List<GraphQLScalarType> {
return listOf(ExtendedScalars.UUID)
}
}
}
}

@DgsComponent
@FunctionalInterface
fun interface ExtendedScalarRegistrar {
Expand Down
Expand Up @@ -37,6 +37,7 @@ internal class DgsExtendedScalarsAutoConfigurationTests {
.hasSingleBean(DgsExtendedScalarsAutoConfiguration.NumbersExtendedScalarsAutoConfiguration::class.java)
.hasSingleBean(DgsExtendedScalarsAutoConfiguration.ObjectsExtendedScalarsAutoConfiguration::class.java)
.hasSingleBean(DgsExtendedScalarsAutoConfiguration.TimeExtendedScalarsAutoConfiguration::class.java)
.hasSingleBean(DgsExtendedScalarsAutoConfiguration.IDsExtendedScalarsAutoConfiguration::class.java)
}
}

Expand Down Expand Up @@ -97,4 +98,16 @@ internal class DgsExtendedScalarsAutoConfigurationTests {
.doesNotHaveBean(DgsExtendedScalarsAutoConfiguration.CharsExtendedScalarsAutoConfiguration::class.java)
}
}

@Test
fun `IDs scalars can be disabled`() {
context.withPropertyValues(
"dgs.graphql.extensions.scalars.ids.enabled=false"
).run { context ->
assertThat(context)
.hasSingleBean(DgsExtendedScalarsAutoConfiguration::class.java)
assertThat(context)
.doesNotHaveBean(DgsExtendedScalarsAutoConfiguration.IDsExtendedScalarsAutoConfiguration::class.java)
}
}
}

0 comments on commit 2791d9d

Please sign in to comment.