Annotation Type SchemaMapping
Resolves a field of an object type of the schema with this method of a
@Controller bean, as in Spring for GraphQL. QueryMapping,
MutationMapping and SubscriptionMapping are this with the root type
filled in.
@Controller
public class BookController {
@QueryMapping
public Book bookById(@Argument("id") String id) { ... }
@SchemaMapping(typeName = "Book")
public Author author(Book book) { ... }
}
A parameter is one of:
- an
Argument, one argument of the field, converted to the parameter's type -- a scalar, an enum, a list or a class of the application's own Arguments, all of them, as aMapor converted to a class- a
DataFetchingEnvironment, for everything else - an
HttpServer.Requestor aWebSocketSession: the transport the operation arrived on, or null on the other one - otherwise, on a field of a type other than the root types, the source: the object whose field this is
The result is the field's value: a scalar, a Map, a List, or a class of
the application's own, whose fields are read through its JSON codec. A
method that throws nulls the field and reports the error; see
GraphQL for how exceptions are classified.
@PreAuthorize and @Secured apply as on any bean method.
-
Optional Element Summary
Optional Elements
-
Element Details
-
typeName
String typeNameThe object type the field belongs to. On a method, empty means the class's@SchemaMappingtype; on a class, the type of every@SchemaMappingand@BatchMappingmethod that names none.- Default:
""
-
value
-
field
-