FragmentFromAnnotation

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>()

Spread the fragment in resolver fragments:

@Resolver(objectValueFragment = "fragment _ on Account { ...UserCoreFields }")
class AccountDisplayNameResolver : AccountResolvers.DisplayName() { ... }

or in subquery operations:

val result = ctx.query("{ viewer { ...UserCoreFields } }")

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

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

The GraphQL fragment definition text declared in @GraphQLFragment.