Skip to content
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

fix-maxBufSize-less-than-preferredBufSize #2109

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions client/src/main/scala/caliban/client/SelectionBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import caliban.client.Operations.IsOperation
import caliban.client.Selection.Directive
import caliban.client.__Value.__ObjectValue
import com.github.plokhotnyuk.jsoniter_scala.core._

import sttp.client3._
import sttp.client3.jsoniter._
import sttp.model.Uri

import scala.collection.immutable.{ Map => SMap }
import scala.util.control.NonFatal
import scala.math.max

/**
* Represents a selection from parent type `Origin` that returns a result of type `A`.
Expand Down Expand Up @@ -73,7 +74,11 @@ sealed trait SelectionBuilder[-Origin, +A] { self =>
readFromString[GraphQLResponse](
payload,
// allow parsing of large payloads
ReaderConfig.withMaxBufSize(payload.length).withMaxCharBufSize(payload.length)
ReaderConfig
.withMaxBufSize(max(max(payload.length, ReaderConfig.maxBufSize), ReaderConfig.preferredBufSize))
.withMaxCharBufSize(
max(max(payload.length, ReaderConfig.maxCharBufSize), ReaderConfig.preferredCharBufSize)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this one just be max(payload.length, ReaderConfig.maxCharBufSize)? The ReaderConfig.preferredCharBufSize will always be smaller than ReaderConfig.maxCharBufSize.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course. I have updated the PR.

)
)
)
catch {
Expand Down