Replies: 4 comments 4 replies
-
The error mentions that it can't find a user defined scalar named DateTime, so I'd start with defining that and see what it does. So basically add the following in your SDL:
|
Beta Was this translation helpful? Give feedback.
-
@oliemansm Thanks for the reply. SchemaParserOptions schemaParserOptions = SchemaParserOptions.newOptions()
.preferGraphQLResolver(true) //customize your options
.build();
GraphQLSchema graphQLSchema = SchemaParser.newParser()
.options(schemaParserOptions)
.file("schema.graphqls")
.resolvers(query, mutation/*, boardResolver*/)
.scalars(ExtendedScalars.DateTime)
.build()
.makeExecutableSchema();
this.graphQL = GraphQL.newGraphQL(graphQLSchema).build(); Looks like DateTime error is gone. .resolvers(query, mutation, boardResolver, userResolver,...............................) I think that there is a way to scan all resolvers without passing them as parameters. |
Beta Was this translation helpful? Give feedback.
-
I solved the issue by this code while I still don't understand why registering datetime scalar in buildWiring() doesn't work @PostConstruct
public void init() throws IOException {
URL url = Resources.getResource("schema.graphqls");
String sdl = Resources.toString(url, Charsets.UTF_8);
GraphQLSchema graphQLSchema = buildSchema(sdl);
this.graphQL = GraphQL.newGraphQL(graphQLSchema).build();
}
private GraphQLSchema buildSchema(String sdl) {
TypeDefinitionRegistry typeRegistry = new SchemaParser().parse(sdl);
RuntimeWiring runtimeWiring = buildWiring();
SchemaGenerator schemaGenerator = new SchemaGenerator();
return schemaGenerator.makeExecutableSchema(typeRegistry, runtimeWiring);
}
private RuntimeWiring buildWiring() {
return RuntimeWiring.newRuntimeWiring()
.scalar(ExtendedScalars.DateTime)
.build();
}
@Bean
public GraphQL graphQL() {
return graphQL;
}
@Bean
public GraphQLScalarType dateTime() {
return ExtendedScalars.DateTime;
} |
Beta Was this translation helpful? Give feedback.
-
I ran into literally same issue and ended up resolving it the same way as @binkoni, but this problem persists when I'm running a test made with @graphqltest annotation.
I'm providing the scalars in this configuration bean:
I understood that @graphqltest is supposed to fetch the configuration beans but not the Component, Repository or Service ones, which I'm trying to mock in the test. The full repository is available here if it helps: https://github.com/EriRan/Criminal-API Full stack trace is here:
|
Beta Was this translation helpful? Give feedback.
-
This is a duplicate issue of #307 but I post new issue because that issue was not resolved completely.
I thought I have configured graphql kickstart to use graphql-extended-scalars
However it fails to compile due to the following error
graphql.kickstart.tools.SchemaClassScannerError: Expected a user-defined GraphQL scalar type with name 'DateTime' but found none!
Here is the full error log
Anyone knows how to resolve this?
Beta Was this translation helpful? Give feedback.
All reactions