Fragment From Annotation
Abstract base class for named GraphQL fragment objects.
Extend this class with a Kotlin singleton object and annotate it with GraphQLFragment to declare a reusable GraphQL fragment.
@GraphQLFragment("""
fragment UserCoreFields on User {
id
name
email
}
""")
object UserCoreFieldsFragment : FragmentFromAnnotation<User>()Content copied to clipboard
Spread the fragment in resolver fragments:
@Resolver(objectValueFragment = "fragment _ on Account { ...UserCoreFields }")
class AccountDisplayNameResolver : AccountResolvers.DisplayName() { ... }Content copied to clipboard
or in subquery operations:
val result = ctx.query("{ viewer { ...UserCoreFields } }")Content copied to clipboard
The subclass must be a Kotlin singleton object annotated with GraphQLFragment. Named fragments are scoped to the tenant module in which they are declared.
Parameters
T
the GraphQL object type on which this fragment selects fields — must be a composite output type (object, interface, or union).
See also
Properties
Link copied to clipboard
The GraphQL fragment definition text declared in @GraphQLFragment.