SchemaShape

gql.SchemaShape$
See theSchemaShape companion class
object SchemaShape

Attributes

Companion
class
Source
SchemaShape.scala
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

final case class DiscoveryState[F[_]](toplevels: Map[String, Toplevel[F, _]], implementations: Implementations[F], positions: Map[String, List[Position[F, _]]])

Attributes

Source
SchemaShape.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object InterfaceImpl

Attributes

Companion
trait
Source
SchemaShape.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait InterfaceImpl[+F[_], A]

Attributes

Companion
object
Source
SchemaShape.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class OtherInterface[F, A]
class TypeImpl[F, A, B]
final class PartiallyAppliedSchemaShape[F[_]](val dummy: Boolean) extends AnyVal

Attributes

Source
SchemaShape.scala
Supertypes
class AnyVal
trait Matchable
class Any
object VisitNode

Attributes

Companion
trait
Source
SchemaShape.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
VisitNode.type
sealed trait VisitNode[+F[_]]

Attributes

Companion
object
Source
SchemaShape.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class FieldNode[F]
class Implementations[F]
class InNode
class OutNode[F]
class OutToplevelNode[F]
object `__TypeKind`

Attributes

Companion
trait
Source
SchemaShape.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait `__TypeKind` extends Product, Serializable

Attributes

Companion
object
Source
SchemaShape.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
object ENUM.type
object INPUT_OBJECT.type
object INTERFACE.type
object LIST.type
object NON_NULL.type
object OBJECT.type
object SCALAR.type
object UNION.type
Show all

Types

Attributes

Source
SchemaShape.scala

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
Source
Mirror.scala

The name of the type

The name of the type

Attributes

Inherited from:
Mirror
Source
Mirror.scala

Value members

Concrete methods

def discover[F[_]](shape: SchemaShape[F, _, _, _]): DiscoveryState[F]

Attributes

Source
SchemaShape.scala
def introspect[F[_]](ss: SchemaShape[F, _, _, _]): NonEmptyList[(String, Field[F, Unit, _])]

Attributes

Source
SchemaShape.scala

Attributes

Source
SchemaShape.scala
def render[F[_]](shape: SchemaShape[F, _, _, _]): String

Attributes

Source
SchemaShape.scala
def renderValueDoc[C](v: Value[AnyValue, C]): Doc

Attributes

Source
SchemaShape.scala
def unit[F[_]](query: NonEmptyList[(String, Field[F, Unit, _])], mutation: Option[NonEmptyList[(String, Field[F, Unit, _])]], subscription: Option[NonEmptyList[(String, Field[F, Unit, _])]], outputTypes: List[OutToplevel[F, _]], inputTypes: List[InToplevel[_]]): SchemaShape[F, Unit, Unit, Unit]

Attributes

Source
SchemaShape.scala
def visit[F[_], G[_] : Parallel, A](root: SchemaShape[F, _, _, _])(pf: PartialFunction[VisitNode[F], G[A] => G[A]])(implicit evidence$8: Monad[G], evidence$9: Parallel[G], D0: Defer[G], M: Monoid[A]): G[A]

A powerful fold over the schema.

A powerful fold over the schema. This functions lets the caller choose how to handle recursion explicitly, which allows Kleisli algebras (Local) to be possible.

For instance, counting the number of fields from parent to leaf:

case class State(leaf: String, fields: Int)
type G[A] = Kleisli[WriterT[Eval, List[State], *], Int, A]
val G = Monad[G]
val L = Local[G, Int]
val T = Tell[G, List[State]]

object & {
  def unapply[A](a: A): Option[(A, A)] = Some((a, a))
}

val states: List[State] = ScheamShape.visit[F, G](schema) {
  case VisitNode.FieldNode(_, _) => (rec: G[Unit]) => L.local(rec)(_ + 1)
  case VisitNode.OutNode((_: Scalar[?] | _: Enum[?]) & tl: Toplevel[F, ?]) => rec =>
    L.ask[Int].flatMap(i => T.tell(List(State(tl.name, i)))) >> rec
}.run(0).run.written.value

Consider that if we used state without being explicit about the recursion, we wouldn't be able to "pop" the field count.

An idiomatic combinator name may be parRecFoldMapM

Attributes

Source
SchemaShape.scala
def visitOnce[F[_], G[_] : Defer, A](root: SchemaShape[F, _, _, _])(pf: PartialFunction[VisitNode[F], G[A]])(implicit evidence$10: Monad[G], evidence$11: Defer[G], A: Monoid[A]): G[A]

Attributes

Source
SchemaShape.scala