feature: configure codegen to add @sharable directive in PageInfo type
Please read our contributor guide before creating an issue. Also consider discussing your idea on the discussion forum first.
Describe the Feature Request
Add custom directives like @cacheControl(maxAge: 30) @shareable @tag(name: "public") to generated types when using codegen to types like Pageinfo and other Connection Types and reflect in the SDL of a running graphql project/server
the generated PageInfo Type should look like below in the SDL:
type PageInfo @cacheControl(maxAge: 30) @shareable @tag(name: "public"){
hasPreviousPage: Boolean!
hasNextPage: Boolean!
startCursor: String
endCursor: String
}
Also can the Connection Type can have 1 more additional field totalCount so that the SDL can look like below:
Connection{
edges:[Edge!]
pageInfo:PageInfo!
totalCount:Int!
}
This will be beneficial to show in UI something like showing results 1-10 out of 500(totalCount) records
Describe Preferred Solution
Allow configuration in pom file in pom or gradle to mention to add @sharable tags in PageInfo tags while generating it and result it in the final SDL
Describe Alternatives
None as such
@kilink can we have something like this? Ultimately i want to generate the Connection types with custom directives on those in SDL so that it can be used in a federated supergraph in codegen, as defining relay based pagination types and managing them in all the subgraphs is not helping when we have to write the logic manually all over again for each query
to be precise the @connection generates the relay pagination types dynamically and adds them to schema, we would like those types to have federated directives support , like let dgs know when generating those types in schema , add federated directives like @sharable, etc what ever the user passes maybe give arguments to @connection directive so that the end result would be like :
type PageInfo @cacheControl(maxAge: 30) @shareable @tag(name: "public"){
hasPreviousPage: Boolean!
hasNextPage: Boolean!
startCursor: String
endCursor: String
}
@srinivasankavitha
HI - codegen is not used to generate SDL. It only generates POJOs based on a statically defined SDL. The framework handles basic dynamic generation of SDL for pagination. If you require more custom logioc, directives, it would be better to manually add that to your SDL rather than using the @connection directive.
Hope this helps.
I think for your custom PageInfo, you should just add it yourself to your schema. The pagination support will only add a PageInfo type if one doesn't already exist.
For the Connection types, I could see an argument for adding a flag to the directive to have it generate the totalCount field. Probably in the meantime you could add a @DgsTypeDefinitionRegistry provider that transforms the Connection type and adds the field?