graphqlgraphql-jsgraphql-javaexpress-graphqlprisma-graphql

The field input type 'Long' is not present when resolving type 'Query' [@6:1]


While to initialize the graphql schema I am getting below error stacktrace.

Invocation of init method failed; nested exception is SchemaProblem{errors=[The field input type 'Long' is not present when resolving type 'Query' [@6:1], The field type 'Long' is not present when resolving type 'ObjectRef' [@17:1]]} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:116) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:397) at

where ObjectRef is my object.

type ObjectRef{
id:Long
qualifier : String
}

I am using below set of jars to compile my project.

compile files('libs/latest/graphql-java-servlet-6.1.3.jar')
compile files('libs/latest/graphql-java-16.2.jar')
compile files('libs/latest/graphql-java-tools-5.2.4.jar')
compile files('libs/latest/graphql-spring-boot-autoconfigure-5.0.2.jar')
compile files('libs/latest/graphql-spring-boot-starter-5.0.2.jar')
compile files('libs/latest/antlr4-runtime-4.9.2.jar')
compile files('libs/lombok-1.16.18.jar')
compile files('libs/latest/graphql-java-extended-scalars-16.0.1.jar')

This is my schema loader.

@PostConstruct
private void loadSchema() throws IOException {
// get the schema
File schemaFile = schemaResource.getFile();
System.out.println(schemaFile.getAbsolutePath());
// parse schema
TypeDefinitionRegistry typeRegistry = new SchemaParser().parse(schemaFile);
System.out.println("type Registry..."+typeRegistry);
RuntimeWiring wiring = buildRuntimeWiring();
System.out.println("wiring..."+wiring);
GraphQLSchema schema = new SchemaGenerator().makeExecutableSchema(typeRegistry, wiring);
System.out.println("schema..."+schema);
graphQL = GraphQL.newGraphQL(schema).build();
}

private RuntimeWiring buildRuntimeWiring() {
System.out.println("buildRuntimeWiring...");
return RuntimeWiring.newRuntimeWiring().type("Query", typeWiring -> typeWiring
.dataFetcher("a", customDataFetcher)
).build();
}

Regards Kushagra


Solution

  • I am able to resolve above issue using Scalars. I have created a new scalar called Long and consume the same using below way in .graphqls. scalar Long return RuntimeWiring.newRuntimeWiring().type("Query", typeWiring -> typeWiring .dataFetcher("a", customDataFetcher).scalar(ExtendedScalars.GraphQLLong)).build(); It will also requires to create a ScalarType implementation to behave in the expected manner. In case anyone required full code, please feel free to ping on this ticket.