using graphql-spqr-spring-boot-starter and graphql-spqr but not able to create Fragment using @GraphQLDirective, not sure if there is anyway to do it.
my intension is to create Fragment through code like
@Data
@GraphQLFragment
public class ProfileFields{
private String name;
private String emailId;
private String phoneNo;
}
and use this fragment in the query below, can someone guide me what are the annotations used for this
{
profile(id: "101"){
...ProfileFields
}
}
That's not how GraphQL works. Fragments are defined by the client ad-hoc. You can not define them ahead of time on the server. The definition of the fragment is a part of the query. There's nothing you need to (or can) do on the server for the fragments to work.
The client could send a query such as:
As for
@GraphQLDirective
, it is used to define schema (server-side) directives. Directives are not related to fragments.