diff --git a/internal/client/client.go b/internal/client/client.go index b2b7ce53..7fd8a617 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -113,5 +113,17 @@ func DialOptsFromFlags(cmd *cobra.Command, token storage.Token) ([]grpc.DialOpti opts = append(opts, grpc.WithAuthority(hostnameOverride)) } + maxMessageSize := cobrautil.MustGetInt(cmd, "max-message-size") + if maxMessageSize != 0 { + opts = append(opts, grpc.WithDefaultCallOptions( + // The default max client message size is 4mb. + // It's conceivable that a sufficiently complex + // schema will easily surpass this, so we set the + // limit higher here. + grpc.MaxCallRecvMsgSize(maxMessageSize), + grpc.MaxCallSendMsgSize(maxMessageSize), + )) + } + return opts, nil } diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 86c5135c..2f55784b 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -75,6 +75,7 @@ func Run() { rootCmd.PersistentFlags().Bool("no-verify-ca", false, "do not attempt to verify the server's certificate chain and host name") rootCmd.PersistentFlags().Bool("debug", false, "enable debug logging") rootCmd.PersistentFlags().String("request-id", "", "optional id to send along with SpiceDB requests for tracing") + rootCmd.PersistentFlags().Int("max-message-size", 0, "maximum size in bytes (defaults to 4mb) of a gRPC message that can be sent or received by zed") _ = rootCmd.PersistentFlags().MarkHidden("debug") // This cannot return its error. versionCmd := &cobra.Command{