4

graphql beta testers,

experimenting with 1.0.0-M6 and wondering how I can register custom scalars from the widely used graphql-java-extended-scalars project. I added

@Bean
public GraphQLScalarType json() {
    return ExtendedScalars.Json;
}

in my application class and

scalar JSON

in my schema file but the the scalar is not picked up during application startup.

Can anyone help ?

Regards, Dirk

D.Dinger
  • 61
  • 3

1 Answers1

7

You can register a custom scalar by contributing a RuntimeWiringConfigurer bean to your application, like this:

@Configuration
public class GraphQlConfig {

    @Bean
    public RuntimeWiringConfigurer runtimeWiringConfigurer() {
        return wiringBuilder -> wiringBuilder.scalar(ExtendedScalars.Json);
    }
}
Brian Clozel
  • 56,583
  • 15
  • 167
  • 176