movio / bramble

A federated GraphQL API gateway
https://movio.github.io/bramble/
MIT License
497 stars 55 forks source link

Add ability to expand gateway handler for plugins #267

Closed suhodolskiy closed 5 months ago

suhodolskiy commented 5 months ago

For example, this will allow you to implement: Disabling introspection based on authentication

func (p *IntrospectionPlugin) SetupGatewayHandler(handler *handler.Server) {
  handler.AroundOperations(
    func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
      if u := authentication.GetRequestUserFromCtx(ctx); u.IsAuthorized() {
        graphql.GetOperationContext(ctx).DisableIntrospection = false
      }

      return next(ctx)
    },
  )
}
suhodolskiy commented 5 months ago

@pkqk Thanks 🙌. When do you plan to release the next version that includes this feature?

pkqk commented 5 months ago

@suhodolskiy I've put out v1.4.14.

We don't have a regular release schedule, we usually release once there's a few meaningful changes in. However if you're using a custom plugin you probably have to build your own main.go so you can pin it to whatever commit you want.