Skip to content

Commit

Permalink
Cleanup ValidationBenchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
kyri-petrou committed Jun 18, 2024
1 parent 2689e86 commit 65406fa
Showing 1 changed file with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class ValidationBenchmark {

def run[A](either: Either[Throwable, A]): A = either.fold(throw _, identity)

def toRootType[R](graphQL: GraphQL[R]): Either[CalibanError, RootType] =
graphQL.validateRootSchema.map { schema =>
def toRootType[R](graphQL: GraphQL[R]): RootType =
run(graphQL.validateRootSchema.map { schema =>
RootType(
schema.query.opType,
schema.mutation.map(_.opType),
schema.subscription.map(_.opType)
)
}
})

import NestedZQueryBenchmarkSchema._

Expand All @@ -36,34 +36,27 @@ class ValidationBenchmark {
val parsedDeepWithArgsQuery = run(Parser.parseQuery(deepWithArgsQuery))
val parsedIntrospectionQuery = run(Parser.parseQuery(ComplexQueryBenchmark.fullIntrospectionQuery))

val simpleType = run(
val simpleType =
toRootType(graphQL[Any, SimpleRoot, Unit, Unit](RootResolver(NestedZQueryBenchmarkSchema.simple100Elements)))
)

val multifieldType =
run(
toRootType(
graphQL[Any, MultifieldRoot, Unit, Unit](
RootResolver(NestedZQueryBenchmarkSchema.multifield100Elements)
)
toRootType(
graphQL[Any, MultifieldRoot, Unit, Unit](
RootResolver(NestedZQueryBenchmarkSchema.multifield100Elements)
)
)

val deepType =
run(
toRootType(
graphQL[Any, DeepRoot, Unit, Unit](
RootResolver[DeepRoot](NestedZQueryBenchmarkSchema.deep100Elements)
)
toRootType(
graphQL[Any, DeepRoot, Unit, Unit](
RootResolver[DeepRoot](NestedZQueryBenchmarkSchema.deep100Elements)
)
)

val deepWithArgsType =
run(
toRootType(
graphQL[Any, DeepWithArgsRoot, Unit, Unit](
RootResolver[DeepWithArgsRoot](NestedZQueryBenchmarkSchema.deepWithArgs100Elements)
)
toRootType(
graphQL[Any, DeepWithArgsRoot, Unit, Unit](
RootResolver[DeepWithArgsRoot](NestedZQueryBenchmarkSchema.deepWithArgs100Elements)
)
)

Expand Down

0 comments on commit 65406fa

Please sign in to comment.