You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
schema {
query: MyQuery
mutation: MyMutation
}
type MyQuery {
hello: String!
}
type MyMutation {
saveGreeting(greeting: String!): String!
}
With a controller
@Controller
public class HelloController {
private String greeting = "Hello";
@QueryMapping
public String hello() {
return greeting;
}
@MutationMapping
public String saveGreeting(@Argument String greeting) {
this.greeting = greeting;
}
}
When sending a request, neither method is invoked and the framework silently returns null - with an error of some form
{
"errors": [
{
"message": "The field at path '/hello' was declared as a non null type, but the code involved in retrieving data has wrongly returned a null value. The graphql specification requires that the parent field be set to null, or if that is non nullable that it bubble up null to its parent and so on. The non-nullable type is 'String' within parent type 'MyQuery'",
"path": [
"hello"
],
"extensions": {
"classification": "NullValueInNonNullableField"
}
}
],
"data": null
}
I also tried changing my annotations @QueryMapping("MyQuery.hello") but that doesn't work either.
Does the framework only support Query and Mutation for the names? That makes it difficult to bring in 3rd party schemas
The text was updated successfully, but these errors were encountered:
Currently @QueryMapping is just a shortcut for @SchemaMapping(typeName="Query"), and as a RuntimeWiringConfigurer the AnnotatedControllerConfigurer does not have access to schema types. We would need to provide it with a TypeDefinitionRegistry where it can look up the names for Query and Mutation types.
I'll schedule this to give it a try. In the mean, you could create your own @MyQueryMappingmeta annotation, following the example of @QueryMapping.
rstoyanchev
changed the title
Does not support renamed Query/Mutation in the schema element
Support custom type names for query, mutation, and subscription operations
May 21, 2023
rstoyanchev
changed the title
Support custom type names for query, mutation, and subscription operations
Replace DataFetcher registrations to match custom root operation type names
Apr 12, 2024
GraphQL (https://spec.graphql.org/October2021/#sec-Schema) allows for the Query and Mutation elements to be renamed as in
With a controller
When sending a request, neither method is invoked and the framework silently returns null - with an error of some form
I also tried changing my annotations @QueryMapping("MyQuery.hello") but that doesn't work either.
Does the framework only support Query and Mutation for the names? That makes it difficult to bring in 3rd party schemas
The text was updated successfully, but these errors were encountered: