-
-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add transformer that excludes fields / inputs based on directives #2293
Conversation
Following @paulpdaniels comment here, I realised we were missing an opportunity to make the transformer work on any directive instead of just the caliban-provided annotations. So now users can do the following: final case class Experimental extends GQLDirective("experimental")
final case class Internal extends GQLDirective("internal")
val apiA: GraphQL[Any] = api.transform(Transformer.ExcludeDirectives(Experimental()))
val apiB: GraphQL[Any] = api.transform(Transformer.ExcludeDirectives(Experimental(), Internal())) |
/** | ||
* Annotation used to provide directives to a schema type | ||
*/ | ||
open class GQLDirective(val directive: Directive) extends StaticAnnotation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made this an open class
in Scala 3, so that users can extend it without having to add the import scala.language.adhocExtensions
import. More info on open classes here
@paulpdaniels I'll merge this PR in, in case there is anything else you'd like me to address let me know and I can do it in a followup PR |
Kind of experimental work based on transformers to allow excluding fields / input arguments based on the
@GQLTag
annotation.This can be particularly helpful for schema versioning, e.g., having a
/beta
and a/v1
endpoint, and excluding fields from/v1
until we're happy with them without breaking compatibility in the APIs