graphql-go-tools icon indicating copy to clipboard operation
graphql-go-tools copied to clipboard

[TT-11737] [PoC] custom Tyk directive @uppercase

Open buraksezer opened this issue 1 year ago • 1 comments

Proof of concept for TT-11737.

  • A custom directive has been added named toUpper.
  • CustomDirective interface has been added. Any struct that implements this interface can be used as a directive.
  • This PoC only works for the proxy-only method. It's easy to extend it.
  • The actual implementation lives in pkg/engine/plan/plan.go and pkg/engine/resolve/resolve.go files.
  • The GraphQL data source takes a map of custom directives, it doesn't push the custom directives to the upstream.
  • The resolver executes the directive's business logic.

Passing the custom directives to the inner layers of the library required some attention but the implementation itself is not too complicated. The directive implementation lives in Tyk GW and it's passed to the library via graphql.NewProxyEngineConfigFactory after initialization.

The PoC PR on the Tyk side. https://github.com/TykTechnologies/tyk/pull/6225

buraksezer avatar Apr 12 '24 12:04 buraksezer