ghostdogpr / caliban

Functional GraphQL library for Scala
https://ghostdogpr.github.io/caliban/
Apache License 2.0
947 stars 248 forks source link

Client Schema generation doesn't handle `_` suffixed names in union types #1766

Closed paulpdaniels closed 1 year ago

paulpdaniels commented 1 year ago

Given a unioned type union _Entity = UserProfile | Plan | Subscription_ | Customer | Organization

The client generation bails with:

error: Query.scala: org.scalafmt.dynamic.exceptions.PositionExceptionImpl: Query.scala:66: error: [dialect scala213] : expected but identifier found
  def _entities[A](representations : List[_Any] = Nil)(onCustomer: SelectionBuilder[Customer, A], onOrganization: SelectionBuilder[Organization, A], onPlan: SelectionBuilder[Plan, A], onSubscription_: SelectionBuilder[`Subscription_`, A], onUserProfile: SelectionBuilder[UserProfile, A])(implicit encoder0: ArgEncoder[List[_Any]]): SelectionBuilder[_root_.caliban.client.Operations.RootQuery, List[scala.Option[A]]] = _root_.caliban.client.SelectionBuilder.Field("_entities", ListOf(OptionOf(ChoiceOf(Map("Customer" -> Obj(onCustomer), "Organization" -> Obj(onOrganization), "Plan" -> Obj(onPlan), "Subscription_" -> Obj(onSubscription_), "UserProfile" -> Obj(onUserProfile))))), arguments = List(Argument("representations", representations, "[_Any!]!")(encoder0)))

Scala version: 2.13.10

ghostdogpr commented 1 year ago

Same as https://github.com/ghostdogpr/caliban/issues/1825