Extend GraphQL types using @GraphQLContext
masterYou can attach additional fields to an existing GraphQL type without modifying the original domain class. To do this, create a query in a service that takes the target type as a parameter annotated with @GraphQLContext. The parameter type becomes the 'context' for the new field.
class UserService {
// This method attaches a 'twitterProfile' field to the 'User' type
@GraphQLQuery
public TwitterProfile twitterProfile(@GraphQLContext User user) {
// logic to fetch profile based on 'user'
return ...;
}
}