diff --git a/docs/404.html b/docs/404.html index 20878f8d6..f3319e94f 100644 --- a/docs/404.html +++ b/docs/404.html @@ -7,11 +7,11 @@ - + -

404

There's nothing here.
Take me home.
- +

404

How did we get here?
Take me home.
+ diff --git a/docs/about/index.html b/docs/about/index.html index d9330a73e..2c12170d9 100644 --- a/docs/about/index.html +++ b/docs/about/index.html @@ -7,7 +7,7 @@ - + @@ -20,6 +20,6 @@

# About

Caliban is a project developed by Pierre Ricadat aka @ghostdogpr.

The name is inspired by the SF novel and tv series The Expanse.

Thanks:

- + diff --git a/docs/assets/js/10.2243bec3.js b/docs/assets/js/10.2243bec3.js new file mode 100644 index 000000000..503d31a30 --- /dev/null +++ b/docs/assets/js/10.2243bec3.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[10],{210:function(t,e,r){"use strict";r.r(e);var n=r(0),a=Object(n.a)({},(function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[r("h1",{attrs:{id:"introspection"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#introspection"}},[t._v("#")]),t._v(" Introspection")]),t._v(" "),r("p",[t._v("Introspection queries are fully supported, which means you can use your favorite tool to inspect your schema and generate documentation for free.")]),t._v(" "),r("p",[t._v("Here's an example of documentation generated by introspection in "),r("a",{attrs:{href:"https://altair.sirmuel.design/",target:"_blank",rel:"noopener noreferrer"}},[t._v("Altair GraphQL Client"),r("OutboundLink")],1),t._v(":")]),t._v(" "),r("p",[r("img",{attrs:{src:"/caliban/altair.png",alt:"altair screenshot"}})])])}),[],!1,null,null,null);e.default=a.exports}}]); \ No newline at end of file diff --git a/docs/assets/js/10.81974ac5.js b/docs/assets/js/11.6e849754.js similarity index 99% rename from docs/assets/js/10.81974ac5.js rename to docs/assets/js/11.6e849754.js index 1f9d40241..c3e2f6a05 100644 --- a/docs/assets/js/10.81974ac5.js +++ b/docs/assets/js/11.6e849754.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[10],{210:function(t,a,s){"use strict";s.r(a);var e=s(0),n=Object(e.a)({},(function(){var t=this,a=t.$createElement,s=t._self._c||a;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"schemas"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#schemas"}},[t._v("#")]),t._v(" Schemas")]),t._v(" "),s("p",[t._v("A GraphQL schema will be derived automatically at compile-time (no reflection) from the types present in your resolver.\nThe table below shows how common Scala types are converted to GraphQL types.")]),t._v(" "),s("table",[s("thead",[s("tr",[s("th",[t._v("Scala Type")]),t._v(" "),s("th",[t._v("GraphQL Type")])])]),t._v(" "),s("tbody",[s("tr",[s("td",[t._v("Boolean")]),t._v(" "),s("td",[t._v("Boolean")])]),t._v(" "),s("tr",[s("td",[t._v("Int")]),t._v(" "),s("td",[t._v("Int")])]),t._v(" "),s("tr",[s("td",[t._v("Float")]),t._v(" "),s("td",[t._v("Float")])]),t._v(" "),s("tr",[s("td",[t._v("String")]),t._v(" "),s("td",[t._v("String")])]),t._v(" "),s("tr",[s("td",[t._v("Unit")]),t._v(" "),s("td",[t._v("Unit (custom scalar)")])]),t._v(" "),s("tr",[s("td",[t._v("Long")]),t._v(" "),s("td",[t._v("Long (custom scalar)")])]),t._v(" "),s("tr",[s("td",[t._v("Double")]),t._v(" "),s("td",[t._v("Double (custom scalar)")])]),t._v(" "),s("tr",[s("td",[t._v("Case Class")]),t._v(" "),s("td",[t._v("Object")])]),t._v(" "),s("tr",[s("td",[t._v("Sealed Trait")]),t._v(" "),s("td",[t._v("Enum or Union")])]),t._v(" "),s("tr",[s("td",[t._v("Option[A]")]),t._v(" "),s("td",[t._v("Nullable A")])]),t._v(" "),s("tr",[s("td",[t._v("List[A]")]),t._v(" "),s("td",[t._v("List of A")])]),t._v(" "),s("tr",[s("td",[t._v("Set[A]")]),t._v(" "),s("td",[t._v("List of A")])]),t._v(" "),s("tr",[s("td",[t._v("A => B")]),t._v(" "),s("td",[t._v("A and B")])]),t._v(" "),s("tr",[s("td",[t._v("(A, B)")]),t._v(" "),s("td",[t._v("Object with 2 fields "),s("code",[t._v("_1")]),t._v(" and "),s("code",[t._v("_2")])])]),t._v(" "),s("tr",[s("td",[t._v("Either[A, B]")]),t._v(" "),s("td",[t._v("Object with 2 nullable fields "),s("code",[t._v("left")]),t._v(" and "),s("code",[t._v("right")])])]),t._v(" "),s("tr",[s("td",[t._v("Map[A, B]")]),t._v(" "),s("td",[t._v("List of Object with 2 fields "),s("code",[t._v("key")]),t._v(" and "),s("code",[t._v("value")])])]),t._v(" "),s("tr",[s("td",[t._v("ZIO[R, E, A]")]),t._v(" "),s("td",[t._v("A")])]),t._v(" "),s("tr",[s("td",[t._v("ZStream[R, E, A]")]),t._v(" "),s("td",[t._v("A")])])])]),t._v(" "),s("p",[t._v("See the "),s("a",{attrs:{href:"#custom-types"}},[t._v("Custom Types")]),t._v(" section to find out how to support your own types.")]),t._v(" "),s("p",[t._v("If you want Caliban to support other standard types, feel free to "),s("a",{attrs:{href:"https://github.com/ghostdogpr/caliban/issues",target:"_blank",rel:"noopener noreferrer"}},[t._v("file an issue"),s("OutboundLink")],1),t._v(" or even a PR.")]),t._v(" "),s("div",{staticClass:"custom-block warning"},[s("p",{staticClass:"custom-block-title"},[t._v("WARNING")]),t._v(" "),s("p",[t._v("Magnolia (the library used to derive the schema at compile-time) sometimes has some trouble generating schemas with a lot of nested types, or types reused in multiple places.\nto deal with this, you can declare schemas for your case classes and sealed traits explicitly:")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("implicit")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" roleSchema "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("gen"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Role"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("implicit")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" characterSchema "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("gen"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n")])])]),s("p",[t._v("Make sure those implicits are in scope when you call "),s("code",[t._v("graphQL(...)")]),t._v(". This will make Magnolia's job easier by pre-generating schemas for those classes and re-using them when needed.\nThis will also improve compilation times and generate less bytecode.")])]),t._v(" "),s("h2",{attrs:{id:"enum-and-union"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#enum-and-union"}},[t._v("#")]),t._v(" Enum and union")]),t._v(" "),s("p",[t._v("A sealed trait will be converted to a different GraphQL type depending on its content:")]),t._v(" "),s("ul",[s("li",[t._v("a sealed trait with only case objects will be converted to an "),s("code",[t._v("ENUM")])]),t._v(" "),s("li",[t._v("a sealed trait with only case classes will be converted to a "),s("code",[t._v("UNION")])])]),t._v(" "),s("p",[t._v('GraphQL does not support empty objects, so in case a sealed trait mixes case classes and case objects, a union type will be created and the case objects will have a "fake" field named '),s("code",[t._v("_")]),t._v(" which is not queryable.")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("sealed")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("trait")]),t._v(" ORIGIN\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" ORIGIN "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" EARTH "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" ORIGIN\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" MARS "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" ORIGIN\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" BELT "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" ORIGIN\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("p",[t._v("The snippet above will produce the following GraphQL type:")]),t._v(" "),s("div",{staticClass:"language-graphql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-graphql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("enum")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Origin")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token constant"}},[t._v("BELT")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token constant"}},[t._v("EARTH")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token constant"}},[t._v("MARS")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("p",[t._v("Here's an example of union:")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("sealed")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("trait")]),t._v(" Role\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" Role "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Captain"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("shipName"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" Role\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Engineer"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("specialty"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" Role\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" Mechanic "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" Role\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("p",[t._v("The snippet above will produce the following GraphQL type:")]),t._v(" "),s("div",{staticClass:"language-graphql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-graphql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("union")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Role")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Captain "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" Engineer "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" Mechanic\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Captain")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("shipName")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" String"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Engineer")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("specialty")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" String"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Mechanic")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("_")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" Boolean"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("h2",{attrs:{id:"arguments"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#arguments"}},[t._v("#")]),t._v(" Arguments")]),t._v(" "),s("p",[t._v("To declare a field that take arguments, create a dedicated case class representing the arguments and make the field a "),s("em",[t._v("function")]),t._v(" from this class to the result type.")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" FilterArgs"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("origin"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Option"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Origin"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("characters"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" FilterArgs "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("=>")]),t._v(" List"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("The snippet above will produce the following GraphQL type:")]),t._v(" "),s("div",{staticClass:"language-graphql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-graphql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Queries")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("characters")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("origin")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" Origin"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" \n")])])]),s("p",[t._v("Caliban provides auto-derivation for common types such as "),s("code",[t._v("Int")]),t._v(", "),s("code",[t._v("String")]),t._v(", "),s("code",[t._v("List")]),t._v(", "),s("code",[t._v("Option")]),t._v(", etc. but you can also support your own types by providing an implicit instance of "),s("code",[t._v("caliban.schema.ArgBuilder")]),t._v(".")]),t._v(" "),s("h2",{attrs:{id:"effects"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#effects"}},[t._v("#")]),t._v(" Effects")]),t._v(" "),s("p",[t._v("Fields can return ZIO effects. This allows you to leverage all the features provided by ZIO: timeouts, retries, access to ZIO environment, memoizing, etc. An effect will be ran every time a query requiring the corresponding field is executed.")]),t._v(" "),s("p",[t._v("If you don't use ZIO environment ("),s("code",[t._v("R")]),t._v(" = "),s("code",[t._v("Any")]),t._v("), there is nothing special to do to get it working.")]),t._v(" "),s("p",[t._v("If you require a ZIO environment, you will need to have the content of "),s("code",[t._v("caliban.schema.GenericSchema[R]")]),t._v(" for your custom "),s("code",[t._v("R")]),t._v(" in scope when you call "),s("code",[t._v("graphQL(...)")]),t._v(".")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" schema "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" GenericSchema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("MyEnv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("_\n")])])]),s("h2",{attrs:{id:"annotations"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#annotations"}},[t._v("#")]),t._v(" Annotations")]),t._v(" "),s("p",[t._v("Caliban supports a few annotation to enrich data types:")]),t._v(" "),s("ul",[s("li",[s("code",[t._v('@GQLName("name")')]),t._v(" allows you to specify a different name for a data type or a field.")]),t._v(" "),s("li",[s("code",[t._v('@GQLDescription("description")')]),t._v(" lets you provide a description for a data type or field. This description will be visible when your schema is introspected.")]),t._v(" "),s("li",[s("code",[t._v('@GQLDeprecated("reason")')]),t._v(" allows deprecating a field or an enum value.")])]),t._v(" "),s("h2",{attrs:{id:"custom-types"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#custom-types"}},[t._v("#")]),t._v(" Custom types")]),t._v(" "),s("p",[t._v("Caliban provides auto-derivation for common types such as "),s("code",[t._v("Int")]),t._v(", "),s("code",[t._v("String")]),t._v(", "),s("code",[t._v("List")]),t._v(", "),s("code",[t._v("Option")]),t._v(", etc. but you can also support your own types by providing an implicit instance of "),s("code",[t._v("caliban.schema.Schema")]),t._v(".")]),t._v(" "),s("p",[t._v("An easy way to do this is to reuse existing instances and use "),s("code",[t._v("contramap")]),t._v(" to map from your type to the original type. Here's an example of creating an instance for "),s("a",{attrs:{href:"https://github.com/fthomas/refined",target:"_blank",rel:"noopener noreferrer"}},[t._v("refined"),s("OutboundLink")],1),t._v("'s "),s("code",[t._v("NonEmptyString")]),t._v(" reusing existing instance for "),s("code",[t._v("String")]),t._v(":")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token namespace"}},[t._v("caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("schema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("_\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("implicit")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" nonEmptyStringSchema"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("NonEmptyString"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("stringSchema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("contramap"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("_"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("value"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("You can also use the "),s("code",[t._v("scalarSchema")]),t._v(" helper to create your own scalar types, providing a name, an optional description, and a function from your type to a "),s("code",[t._v("ResponseValue")]),t._v(":")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token namespace"}},[t._v("caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("schema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("_\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("implicit")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" unitSchema"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Unit")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" scalarSchema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Unit"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" None"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" _ "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("=>")]),t._v(" ObjectValue"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("Nil"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])}),[],!1,null,null,null);a.default=n.exports}}]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[11],{211:function(t,a,s){"use strict";s.r(a);var e=s(0),n=Object(e.a)({},(function(){var t=this,a=t.$createElement,s=t._self._c||a;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"schemas"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#schemas"}},[t._v("#")]),t._v(" Schemas")]),t._v(" "),s("p",[t._v("A GraphQL schema will be derived automatically at compile-time (no reflection) from the types present in your resolver.\nThe table below shows how common Scala types are converted to GraphQL types.")]),t._v(" "),s("table",[s("thead",[s("tr",[s("th",[t._v("Scala Type")]),t._v(" "),s("th",[t._v("GraphQL Type")])])]),t._v(" "),s("tbody",[s("tr",[s("td",[t._v("Boolean")]),t._v(" "),s("td",[t._v("Boolean")])]),t._v(" "),s("tr",[s("td",[t._v("Int")]),t._v(" "),s("td",[t._v("Int")])]),t._v(" "),s("tr",[s("td",[t._v("Float")]),t._v(" "),s("td",[t._v("Float")])]),t._v(" "),s("tr",[s("td",[t._v("String")]),t._v(" "),s("td",[t._v("String")])]),t._v(" "),s("tr",[s("td",[t._v("Unit")]),t._v(" "),s("td",[t._v("Unit (custom scalar)")])]),t._v(" "),s("tr",[s("td",[t._v("Long")]),t._v(" "),s("td",[t._v("Long (custom scalar)")])]),t._v(" "),s("tr",[s("td",[t._v("Double")]),t._v(" "),s("td",[t._v("Double (custom scalar)")])]),t._v(" "),s("tr",[s("td",[t._v("Case Class")]),t._v(" "),s("td",[t._v("Object")])]),t._v(" "),s("tr",[s("td",[t._v("Sealed Trait")]),t._v(" "),s("td",[t._v("Enum or Union")])]),t._v(" "),s("tr",[s("td",[t._v("Option[A]")]),t._v(" "),s("td",[t._v("Nullable A")])]),t._v(" "),s("tr",[s("td",[t._v("List[A]")]),t._v(" "),s("td",[t._v("List of A")])]),t._v(" "),s("tr",[s("td",[t._v("Set[A]")]),t._v(" "),s("td",[t._v("List of A")])]),t._v(" "),s("tr",[s("td",[t._v("A => B")]),t._v(" "),s("td",[t._v("A and B")])]),t._v(" "),s("tr",[s("td",[t._v("(A, B)")]),t._v(" "),s("td",[t._v("Object with 2 fields "),s("code",[t._v("_1")]),t._v(" and "),s("code",[t._v("_2")])])]),t._v(" "),s("tr",[s("td",[t._v("Either[A, B]")]),t._v(" "),s("td",[t._v("Object with 2 nullable fields "),s("code",[t._v("left")]),t._v(" and "),s("code",[t._v("right")])])]),t._v(" "),s("tr",[s("td",[t._v("Map[A, B]")]),t._v(" "),s("td",[t._v("List of Object with 2 fields "),s("code",[t._v("key")]),t._v(" and "),s("code",[t._v("value")])])]),t._v(" "),s("tr",[s("td",[t._v("ZIO[R, E, A]")]),t._v(" "),s("td",[t._v("A")])]),t._v(" "),s("tr",[s("td",[t._v("ZStream[R, E, A]")]),t._v(" "),s("td",[t._v("A")])])])]),t._v(" "),s("p",[t._v("See the "),s("a",{attrs:{href:"#custom-types"}},[t._v("Custom Types")]),t._v(" section to find out how to support your own types.")]),t._v(" "),s("p",[t._v("If you want Caliban to support other standard types, feel free to "),s("a",{attrs:{href:"https://github.com/ghostdogpr/caliban/issues",target:"_blank",rel:"noopener noreferrer"}},[t._v("file an issue"),s("OutboundLink")],1),t._v(" or even a PR.")]),t._v(" "),s("div",{staticClass:"custom-block warning"},[s("p",{staticClass:"custom-block-title"},[t._v("WARNING")]),t._v(" "),s("p",[t._v("Magnolia (the library used to derive the schema at compile-time) sometimes has some trouble generating schemas with a lot of nested types, or types reused in multiple places.\nto deal with this, you can declare schemas for your case classes and sealed traits explicitly:")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("implicit")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" roleSchema "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("gen"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Role"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("implicit")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" characterSchema "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("gen"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n")])])]),s("p",[t._v("Make sure those implicits are in scope when you call "),s("code",[t._v("graphQL(...)")]),t._v(". This will make Magnolia's job easier by pre-generating schemas for those classes and re-using them when needed.\nThis will also improve compilation times and generate less bytecode.")])]),t._v(" "),s("h2",{attrs:{id:"enum-and-union"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#enum-and-union"}},[t._v("#")]),t._v(" Enum and union")]),t._v(" "),s("p",[t._v("A sealed trait will be converted to a different GraphQL type depending on its content:")]),t._v(" "),s("ul",[s("li",[t._v("a sealed trait with only case objects will be converted to an "),s("code",[t._v("ENUM")])]),t._v(" "),s("li",[t._v("a sealed trait with only case classes will be converted to a "),s("code",[t._v("UNION")])])]),t._v(" "),s("p",[t._v('GraphQL does not support empty objects, so in case a sealed trait mixes case classes and case objects, a union type will be created and the case objects will have a "fake" field named '),s("code",[t._v("_")]),t._v(" which is not queryable.")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("sealed")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("trait")]),t._v(" ORIGIN\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" ORIGIN "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" EARTH "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" ORIGIN\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" MARS "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" ORIGIN\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" BELT "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" ORIGIN\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("p",[t._v("The snippet above will produce the following GraphQL type:")]),t._v(" "),s("div",{staticClass:"language-graphql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-graphql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("enum")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Origin")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token constant"}},[t._v("BELT")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token constant"}},[t._v("EARTH")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token constant"}},[t._v("MARS")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("p",[t._v("Here's an example of union:")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("sealed")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("trait")]),t._v(" Role\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" Role "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Captain"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("shipName"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" Role\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Engineer"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("specialty"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" Role\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" Mechanic "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" Role\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("p",[t._v("The snippet above will produce the following GraphQL type:")]),t._v(" "),s("div",{staticClass:"language-graphql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-graphql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("union")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Role")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Captain "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" Engineer "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" Mechanic\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Captain")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("shipName")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" String"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Engineer")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("specialty")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" String"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Mechanic")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("_")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" Boolean"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("h2",{attrs:{id:"arguments"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#arguments"}},[t._v("#")]),t._v(" Arguments")]),t._v(" "),s("p",[t._v("To declare a field that take arguments, create a dedicated case class representing the arguments and make the field a "),s("em",[t._v("function")]),t._v(" from this class to the result type.")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" FilterArgs"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("origin"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Option"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Origin"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("characters"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" FilterArgs "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("=>")]),t._v(" List"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("The snippet above will produce the following GraphQL type:")]),t._v(" "),s("div",{staticClass:"language-graphql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-graphql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Queries")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("characters")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("origin")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" Origin"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" \n")])])]),s("p",[t._v("Caliban provides auto-derivation for common types such as "),s("code",[t._v("Int")]),t._v(", "),s("code",[t._v("String")]),t._v(", "),s("code",[t._v("List")]),t._v(", "),s("code",[t._v("Option")]),t._v(", etc. but you can also support your own types by providing an implicit instance of "),s("code",[t._v("caliban.schema.ArgBuilder")]),t._v(".")]),t._v(" "),s("h2",{attrs:{id:"effects"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#effects"}},[t._v("#")]),t._v(" Effects")]),t._v(" "),s("p",[t._v("Fields can return ZIO effects. This allows you to leverage all the features provided by ZIO: timeouts, retries, access to ZIO environment, memoizing, etc. An effect will be ran every time a query requiring the corresponding field is executed.")]),t._v(" "),s("p",[t._v("If you don't use ZIO environment ("),s("code",[t._v("R")]),t._v(" = "),s("code",[t._v("Any")]),t._v("), there is nothing special to do to get it working.")]),t._v(" "),s("p",[t._v("If you require a ZIO environment, you will need to have the content of "),s("code",[t._v("caliban.schema.GenericSchema[R]")]),t._v(" for your custom "),s("code",[t._v("R")]),t._v(" in scope when you call "),s("code",[t._v("graphQL(...)")]),t._v(".")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" schema "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" GenericSchema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("MyEnv"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("_\n")])])]),s("h2",{attrs:{id:"annotations"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#annotations"}},[t._v("#")]),t._v(" Annotations")]),t._v(" "),s("p",[t._v("Caliban supports a few annotation to enrich data types:")]),t._v(" "),s("ul",[s("li",[s("code",[t._v('@GQLName("name")')]),t._v(" allows you to specify a different name for a data type or a field.")]),t._v(" "),s("li",[s("code",[t._v('@GQLDescription("description")')]),t._v(" lets you provide a description for a data type or field. This description will be visible when your schema is introspected.")]),t._v(" "),s("li",[s("code",[t._v('@GQLDeprecated("reason")')]),t._v(" allows deprecating a field or an enum value.")])]),t._v(" "),s("h2",{attrs:{id:"custom-types"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#custom-types"}},[t._v("#")]),t._v(" Custom types")]),t._v(" "),s("p",[t._v("Caliban provides auto-derivation for common types such as "),s("code",[t._v("Int")]),t._v(", "),s("code",[t._v("String")]),t._v(", "),s("code",[t._v("List")]),t._v(", "),s("code",[t._v("Option")]),t._v(", etc. but you can also support your own types by providing an implicit instance of "),s("code",[t._v("caliban.schema.Schema")]),t._v(".")]),t._v(" "),s("p",[t._v("An easy way to do this is to reuse existing instances and use "),s("code",[t._v("contramap")]),t._v(" to map from your type to the original type. Here's an example of creating an instance for "),s("a",{attrs:{href:"https://github.com/fthomas/refined",target:"_blank",rel:"noopener noreferrer"}},[t._v("refined"),s("OutboundLink")],1),t._v("'s "),s("code",[t._v("NonEmptyString")]),t._v(" reusing existing instance for "),s("code",[t._v("String")]),t._v(":")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token namespace"}},[t._v("caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("schema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("_\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("implicit")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" nonEmptyStringSchema"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("NonEmptyString"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("stringSchema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("contramap"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("_"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("value"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("You can also use the "),s("code",[t._v("scalarSchema")]),t._v(" helper to create your own scalar types, providing a name, an optional description, and a function from your type to a "),s("code",[t._v("ResponseValue")]),t._v(":")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token namespace"}},[t._v("caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("schema")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("_\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("implicit")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" unitSchema"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Schema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Unit")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" scalarSchema"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Unit"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" None"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" _ "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("=>")]),t._v(" ObjectValue"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("Nil"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])])])}),[],!1,null,null,null);a.default=n.exports}}]); \ No newline at end of file diff --git a/docs/assets/js/11.8e083f04.js b/docs/assets/js/12.024b38dd.js similarity index 97% rename from docs/assets/js/11.8e083f04.js rename to docs/assets/js/12.024b38dd.js index 66e6aeb31..25377e59a 100644 --- a/docs/assets/js/11.8e083f04.js +++ b/docs/assets/js/12.024b38dd.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[11],{211:function(a,t,s){"use strict";s.r(t);var e=s(0),n=Object(e.a)({},(function(){var a=this,t=a.$createElement,s=a._self._c||t;return s("ContentSlotsDistributor",{attrs:{"slot-key":a.$parent.slotKey}},[s("h1",{attrs:{id:"validation"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#validation"}},[a._v("#")]),a._v(" Validation")]),a._v(" "),s("p",[a._v("Caliban provides a little macro called "),s("code",[a._v("gqldoc")]),a._v(" that can check at "),s("strong",[a._v("compile-time")]),a._v(" that a GraphQL query (a "),s("em",[a._v("document")]),a._v(" to be exact) has valid syntax.")]),a._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("import")]),a._v(" caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),a._v("Macros"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),a._v("gqldoc\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("val")]),a._v(" query "),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),a._v(" gqldoc"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[a._v('"""\n query test {\n amos: character(name: "Amos Burton") {\n name\n }\n }"""')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),a._v("\n")])])]),s("p",[a._v("At "),s("strong",[a._v("runtime")]),a._v(", it is possible to validate a query against your schema by calling the method "),s("code",[a._v("check")]),a._v(" on your interpreter.")]),a._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("def")]),a._v(" check"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("query"),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v(":")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[a._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v(":")]),a._v(" IO"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("[")]),a._v("CalibanError"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[a._v("Unit")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("]")]),a._v("\n")])])]),s("p",[a._v("It is also possible to skip validation when executing a query by passing "),s("code",[a._v("skipValidation = true")]),a._v(" when calling "),s("code",[a._v("execute")]),a._v(". This will slightly improve performance.")])])}),[],!1,null,null,null);t.default=n.exports}}]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[12],{212:function(a,t,s){"use strict";s.r(t);var e=s(0),n=Object(e.a)({},(function(){var a=this,t=a.$createElement,s=a._self._c||t;return s("ContentSlotsDistributor",{attrs:{"slot-key":a.$parent.slotKey}},[s("h1",{attrs:{id:"validation"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#validation"}},[a._v("#")]),a._v(" Validation")]),a._v(" "),s("p",[a._v("Caliban provides a little macro called "),s("code",[a._v("gqldoc")]),a._v(" that can check at "),s("strong",[a._v("compile-time")]),a._v(" that a GraphQL query (a "),s("em",[a._v("document")]),a._v(" to be exact) has valid syntax.")]),a._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("import")]),a._v(" caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),a._v("Macros"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),a._v("gqldoc\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("val")]),a._v(" query "),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),a._v(" gqldoc"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),s("span",{pre:!0,attrs:{class:"token string"}},[a._v('"""\n query test {\n amos: character(name: "Amos Burton") {\n name\n }\n }"""')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),a._v("\n")])])]),s("p",[a._v("At "),s("strong",[a._v("runtime")]),a._v(", it is possible to validate a query against your schema by calling the method "),s("code",[a._v("check")]),a._v(" on your interpreter.")]),a._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("def")]),a._v(" check"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("query"),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v(":")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[a._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v(":")]),a._v(" IO"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("[")]),a._v("CalibanError"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[a._v("Unit")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("]")]),a._v("\n")])])]),s("p",[a._v("It is also possible to skip validation when executing a query by passing "),s("code",[a._v("skipValidation = true")]),a._v(" when calling "),s("code",[a._v("execute")]),a._v(". This will slightly improve performance.")])])}),[],!1,null,null,null);t.default=n.exports}}]); \ No newline at end of file diff --git a/docs/assets/js/12.92a30e99.js b/docs/assets/js/12.92a30e99.js deleted file mode 100644 index 8dc2986b4..000000000 --- a/docs/assets/js/12.92a30e99.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[12],{9:function(n,w,o){}}]); \ No newline at end of file diff --git a/docs/assets/js/13.6d9a21ca.js b/docs/assets/js/13.6d9a21ca.js new file mode 100644 index 000000000..5e196e7a2 --- /dev/null +++ b/docs/assets/js/13.6d9a21ca.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[13],{9:function(n,w,o){}}]); \ No newline at end of file diff --git a/docs/assets/js/3.e65bee64.js b/docs/assets/js/3.f2c860b9.js similarity index 87% rename from docs/assets/js/3.e65bee64.js rename to docs/assets/js/3.f2c860b9.js index eb1f99daa..faacb62cd 100644 --- a/docs/assets/js/3.e65bee64.js +++ b/docs/assets/js/3.f2c860b9.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{202:function(t,e,n){"use strict";var i=n(72);n.n(i).a},212:function(t,e,n){"use strict";n.r(e);var i={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:function(t,e){var n=e.props,i=e.slots;return t("span",{class:["badge",n.type],style:{verticalAlign:n.vertical}},n.text||i().default)}},r=(n(202),n(0)),a=Object(r.a)(i,void 0,void 0,!1,null,"c13ee5b0",null);e.default=a.exports},72:function(t,e,n){}}]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{202:function(t,e,n){"use strict";var i=n(72);n.n(i).a},213:function(t,e,n){"use strict";n.r(e);var i={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:function(t,e){var n=e.props,i=e.slots;return t("span",{class:["badge",n.type],style:{verticalAlign:n.vertical}},n.text||i().default)}},r=(n(202),n(0)),a=Object(r.a)(i,void 0,void 0,!1,null,"c13ee5b0",null);e.default=a.exports},72:function(t,e,n){}}]); \ No newline at end of file diff --git a/docs/assets/js/7.41d0b2ab.js b/docs/assets/js/7.41d0b2ab.js deleted file mode 100644 index eba54a3e2..000000000 --- a/docs/assets/js/7.41d0b2ab.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{207:function(t,a,s){"use strict";s.r(a);var e=s(0),r=Object(e.a)({},(function(){var t=this,a=t.$createElement,s=t._self._c||a;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"getting-started"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#getting-started"}},[t._v("#")]),t._v(" Getting Started")]),t._v(" "),s("p",[s("strong",[t._v("Caliban")]),t._v(" is a purely functional library for creating GraphQL backends in Scala.\nIt relies on "),s("a",{attrs:{href:"https://github.com/propensive/magnolia",target:"_blank",rel:"noopener noreferrer"}},[t._v("Magnolia"),s("OutboundLink")],1),t._v(" to automatically derives GraphQL schemas from your data types, "),s("a",{attrs:{href:"https://github.com/lihaoyi/fastparse",target:"_blank",rel:"noopener noreferrer"}},[t._v("Fastparse"),s("OutboundLink")],1),t._v(" to parse queries and "),s("a",{attrs:{href:"https://github.com/zio/zio",target:"_blank",rel:"noopener noreferrer"}},[t._v("ZIO"),s("OutboundLink")],1),t._v(" to handle various effects.")]),t._v(" "),s("p",[t._v("The design principles behind the library are the following:")]),t._v(" "),s("ul",[s("li",[t._v("pure interface: errors and effects are returned explicitly (no exceptions thrown), all returned types are referentially transparent (no "),s("code",[t._v("Future")]),t._v(").")]),t._v(" "),s("li",[t._v("clean separation between schema definition and implementation: schema is defined and validated at compile-time (no reflection) using Scala standard types, resolver is a simple value provided at runtime.")]),t._v(" "),s("li",[t._v("minimal amount of boilerplate: no need to manually define a schema for every type in your API.")])]),t._v(" "),s("h2",{attrs:{id:"dependencies"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#dependencies"}},[t._v("#")]),t._v(" Dependencies")]),t._v(" "),s("p",[t._v("To use "),s("code",[t._v("caliban")]),t._v(", add the following line in your "),s("code",[t._v("build.sbt")]),t._v(" file:")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v('libraryDependencies += "com.github.ghostdogpr" %% "caliban" % "0.1.0"\n')])])]),s("p",[t._v("Note that Caliban is also available for ScalaJS.")]),t._v(" "),s("h2",{attrs:{id:"a-simple-example"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#a-simple-example"}},[t._v("#")]),t._v(" A simple example")]),t._v(" "),s("p",[t._v("Creating a GraphQL API with Caliban is as simple as creating a case class. Indeed, the whole GraphQL schema will be derived from a case class structure (its fields and the other types it references), and the resolver is just an instance of that case class.")]),t._v(" "),s("p",[t._v("Let's say we have a class "),s("code",[t._v("Character")]),t._v(" and 2 functions: "),s("code",[t._v("getCharacters")]),t._v(" and "),s("code",[t._v("getCharacter")]),t._v(":")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("name"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("def")]),t._v(" getCharacters"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" List"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("def")]),t._v(" getCharacter"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("name"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Option"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),t._v("\n")])])]),s("p",[t._v("Let's create a case class named "),s("code",[t._v("Queries")]),t._v(" that will represent our API, with 2 fields named and modeled after the functions we want to expose (a "),s("em",[t._v("record of functions")]),t._v("). We then create a value of this class that calls our actual functions. This is our resolver.")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// schema")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" CharacterName"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("name"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("characters"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" List"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n character"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" CharacterName "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("=>")]),t._v(" Option"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// resolver")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" queries "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("getCharacters"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" args "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("=>")]),t._v(" getCharacter"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("args"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("name"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("The next step is creating our graphql interpreter. First, we wrap our query resolver inside a "),s("code",[t._v("RootResolver")]),t._v(", the root object that contains queries, mutations and subscriptions. Only queries are mandatory. Then we can call the "),s("code",[t._v("graphQL")]),t._v(" function which will turn our simple resolver value into an interpreter. The whole schema will be derived at compile time, meaning that if it compiles, it will be able to serve it.")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("GraphQL"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("graphQL\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("RootResolver\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" interpreter "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" graphQL"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("RootResolver"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("You can use "),s("code",[t._v("interpreter.render")]),t._v(" to visualize the schema generated, in this case:")]),t._v(" "),s("div",{staticClass:"language-graphql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-graphql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Character")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("name")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" String"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Queries")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("characters")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("p",[t._v("Now you can call "),s("code",[t._v("interpreter.execute")]),t._v(" with a given GraphQL query, and you will get an "),s("code",[t._v("ZIO[R, CalibanError, ResponseValue]")]),t._v(" as a response. Use "),s("code",[t._v("ResponseValue#toString")]),t._v(" to get the JSON representation of the result.")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" query "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"""\n { \n characters {\n name\n }\n }"""')]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("for")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n result "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("<-")]),t._v(" interpreter"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("execute"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("query"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n _ "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("<-")]),t._v(" zio"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("console"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("putStrLn"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("result"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("toString"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("yield")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("The "),s("code",[t._v("CalibanError")]),t._v(" can be:")]),t._v(" "),s("ul",[s("li",[t._v("a "),s("code",[t._v("ParsingError")]),t._v(": the query has invalid syntax")]),t._v(" "),s("li",[t._v("a "),s("code",[t._v("ValidationError")]),t._v(": the query was parsed but does not match the schema")]),t._v(" "),s("li",[t._v("an "),s("code",[t._v("ExecutionError")]),t._v(": an error happened while executing the query")])]),t._v(" "),s("p",[t._v("Caliban itself is not tied to any web framework, you are free to expose this function using the protocol and library of your choice. The "),s("a",{attrs:{href:"https://github.com/ghostdogpr/caliban/tree/master/http4s",target:"_blank",rel:"noopener noreferrer"}},[t._v("caliban-http4s"),s("OutboundLink")],1),t._v(" module provides an "),s("code",[t._v("Http4sAdapter")]),t._v(" that exposes an interpreter over HTTP and WebSocket using http4s.")]),t._v(" "),s("h2",{attrs:{id:"mutations"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#mutations"}},[t._v("#")]),t._v(" Mutations")]),t._v(" "),s("p",[t._v("Creating mutations is the same as queries, except you pass them as the second argument to "),s("code",[t._v("RootResolver")]),t._v(":")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" CharacterArgs"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("name"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Mutations"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("deleteCharacter"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" CharacterArgs "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("=>")]),t._v(" Task"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Boolean")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" mutations "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Mutations"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" interpreter "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" graphQL"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("RootResolver"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" mutations"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("h2",{attrs:{id:"subscriptions"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#subscriptions"}},[t._v("#")]),t._v(" Subscriptions")]),t._v(" "),s("p",[t._v("Similarly, subscriptions are passed as the third argument to "),s("code",[t._v("RootResolver")]),t._v(":")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Subscriptions"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("deletedCharacter"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" ZStream"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Any")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Nothing")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" subscriptions "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Subscriptions"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" interpreter "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" graphQL"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("RootResolver"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" mutations"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" subscriptions"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("All the fields of the subscription root case class MUST return "),s("code",[t._v("ZStream")]),t._v(" objects. When a subscription request is received, an output stream of "),s("code",[t._v("ResponseValue")]),t._v(" will be returned wrapped in an "),s("code",[t._v("ObjectValue")]),t._v(".")])])}),[],!1,null,null,null);a.default=r.exports}}]); \ No newline at end of file diff --git a/docs/assets/js/7.e8bcb6d7.js b/docs/assets/js/7.e8bcb6d7.js new file mode 100644 index 000000000..ecefe4d08 --- /dev/null +++ b/docs/assets/js/7.e8bcb6d7.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{207:function(t,a,s){"use strict";s.r(a);var e=s(0),r=Object(e.a)({},(function(){var t=this,a=t.$createElement,s=t._self._c||a;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"getting-started"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#getting-started"}},[t._v("#")]),t._v(" Getting Started")]),t._v(" "),s("p",[s("strong",[t._v("Caliban")]),t._v(" is a purely functional library for creating GraphQL backends in Scala.\nIt relies on "),s("a",{attrs:{href:"https://github.com/propensive/magnolia",target:"_blank",rel:"noopener noreferrer"}},[t._v("Magnolia"),s("OutboundLink")],1),t._v(" to automatically derives GraphQL schemas from your data types, "),s("a",{attrs:{href:"https://github.com/lihaoyi/fastparse",target:"_blank",rel:"noopener noreferrer"}},[t._v("Fastparse"),s("OutboundLink")],1),t._v(" to parse queries and "),s("a",{attrs:{href:"https://github.com/zio/zio",target:"_blank",rel:"noopener noreferrer"}},[t._v("ZIO"),s("OutboundLink")],1),t._v(" to handle various effects.")]),t._v(" "),s("p",[t._v("The design principles behind the library are the following:")]),t._v(" "),s("ul",[s("li",[t._v("pure interface: errors and effects are returned explicitly (no exceptions thrown), all returned types are referentially transparent (no "),s("code",[t._v("Future")]),t._v(").")]),t._v(" "),s("li",[t._v("clean separation between schema definition and implementation: schema is defined and validated at compile-time (no reflection) using Scala standard types, resolver is a simple value provided at runtime.")]),t._v(" "),s("li",[t._v("minimal amount of boilerplate: no need to manually define a schema for every type in your API.")])]),t._v(" "),s("h2",{attrs:{id:"dependencies"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#dependencies"}},[t._v("#")]),t._v(" Dependencies")]),t._v(" "),s("p",[t._v("To use "),s("code",[t._v("caliban")]),t._v(", add the following line in your "),s("code",[t._v("build.sbt")]),t._v(" file:")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v('libraryDependencies += "com.github.ghostdogpr" %% "caliban" % "0.1.0"\n')])])]),s("p",[t._v("The following modules are optional:")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v('libraryDependencies += "com.github.ghostdogpr" %% "caliban-http4s" % "0.1.0" // routes for http4s\nlibraryDependencies += "com.github.ghostdogpr" %% "caliban-cats" % "TODO" // interop with cats effect\n')])])]),s("p",[t._v("Note that Caliban is also available for ScalaJS.")]),t._v(" "),s("h2",{attrs:{id:"a-simple-example"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#a-simple-example"}},[t._v("#")]),t._v(" A simple example")]),t._v(" "),s("p",[t._v("Creating a GraphQL API with Caliban is as simple as creating a case class. Indeed, the whole GraphQL schema will be derived from a case class structure (its fields and the other types it references), and the resolver is just an instance of that case class.")]),t._v(" "),s("p",[t._v("Let's say we have a class "),s("code",[t._v("Character")]),t._v(" and 2 functions: "),s("code",[t._v("getCharacters")]),t._v(" and "),s("code",[t._v("getCharacter")]),t._v(":")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("name"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("def")]),t._v(" getCharacters"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" List"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("def")]),t._v(" getCharacter"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("name"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" Option"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),t._v("\n")])])]),s("p",[t._v("Let's create a case class named "),s("code",[t._v("Queries")]),t._v(" that will represent our API, with 2 fields named and modeled after the functions we want to expose (a "),s("em",[t._v("record of functions")]),t._v("). We then create a value of this class that calls our actual functions. This is our resolver.")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// schema")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" CharacterName"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("name"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("characters"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" List"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n character"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" CharacterName "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("=>")]),t._v(" Option"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// resolver")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" queries "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("getCharacters"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" args "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("=>")]),t._v(" getCharacter"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("args"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("name"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("The next step is creating our graphql interpreter. First, we wrap our query resolver inside a "),s("code",[t._v("RootResolver")]),t._v(", the root object that contains queries, mutations and subscriptions. Only queries are mandatory. Then we can call the "),s("code",[t._v("graphQL")]),t._v(" function which will turn our simple resolver value into an interpreter. The whole schema will be derived at compile time, meaning that if it compiles, it will be able to serve it.")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("GraphQL"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("graphQL\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("RootResolver\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" interpreter "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" graphQL"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("RootResolver"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("You can use "),s("code",[t._v("interpreter.render")]),t._v(" to visualize the schema generated, in this case:")]),t._v(" "),s("div",{staticClass:"language-graphql extra-class"},[s("pre",{pre:!0,attrs:{class:"language-graphql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Character")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("name")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" String"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("type")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Queries")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("characters")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("Character"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("p",[t._v("Now you can call "),s("code",[t._v("interpreter.execute")]),t._v(" with a given GraphQL query, and you will get an "),s("code",[t._v("ZIO[R, CalibanError, ResponseValue]")]),t._v(" as a response. Use "),s("code",[t._v("ResponseValue#toString")]),t._v(" to get the JSON representation of the result.")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" query "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"""\n { \n characters {\n name\n }\n }"""')]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("for")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n result "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("<-")]),t._v(" interpreter"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("execute"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("query"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n _ "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("<-")]),t._v(" zio"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("console"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("putStrLn"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("result"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("toString"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("yield")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("The "),s("code",[t._v("CalibanError")]),t._v(" can be:")]),t._v(" "),s("ul",[s("li",[t._v("a "),s("code",[t._v("ParsingError")]),t._v(": the query has invalid syntax")]),t._v(" "),s("li",[t._v("a "),s("code",[t._v("ValidationError")]),t._v(": the query was parsed but does not match the schema")]),t._v(" "),s("li",[t._v("an "),s("code",[t._v("ExecutionError")]),t._v(": an error happened while executing the query")])]),t._v(" "),s("p",[t._v("Caliban itself is not tied to any web framework, you are free to expose this function using the protocol and library of your choice. The "),s("a",{attrs:{href:"https://github.com/ghostdogpr/caliban/tree/master/http4s",target:"_blank",rel:"noopener noreferrer"}},[t._v("caliban-http4s"),s("OutboundLink")],1),t._v(" module provides an "),s("code",[t._v("Http4sAdapter")]),t._v(" that exposes an interpreter over HTTP and WebSocket using http4s.")]),t._v(" "),s("h2",{attrs:{id:"mutations"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#mutations"}},[t._v("#")]),t._v(" Mutations")]),t._v(" "),s("p",[t._v("Creating mutations is the same as queries, except you pass them as the second argument to "),s("code",[t._v("RootResolver")]),t._v(":")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" CharacterArgs"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("name"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Mutations"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("deleteCharacter"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" CharacterArgs "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("=>")]),t._v(" Task"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Boolean")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" mutations "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Mutations"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" interpreter "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" graphQL"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("RootResolver"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" mutations"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("h2",{attrs:{id:"subscriptions"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#subscriptions"}},[t._v("#")]),t._v(" Subscriptions")]),t._v(" "),s("p",[t._v("Similarly, subscriptions are passed as the third argument to "),s("code",[t._v("RootResolver")]),t._v(":")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Subscriptions"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("deletedCharacter"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" ZStream"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Any")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Nothing")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" Character"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" subscriptions "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Subscriptions"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("?")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" interpreter "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" graphQL"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("RootResolver"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" mutations"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" subscriptions"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n")])])]),s("p",[t._v("All the fields of the subscription root case class MUST return "),s("code",[t._v("ZStream")]),t._v(" objects. When a subscription request is received, an output stream of "),s("code",[t._v("ResponseValue")]),t._v(" will be returned wrapped in an "),s("code",[t._v("ObjectValue")]),t._v(".")])])}),[],!1,null,null,null);a.default=r.exports}}]); \ No newline at end of file diff --git a/docs/assets/js/8.ed06393e.js b/docs/assets/js/8.90f7e1a9.js similarity index 92% rename from docs/assets/js/8.ed06393e.js rename to docs/assets/js/8.90f7e1a9.js index 21dba4dcf..81e6fea51 100644 --- a/docs/assets/js/8.ed06393e.js +++ b/docs/assets/js/8.90f7e1a9.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{208:function(e,t,r){"use strict";r.r(t);var a=r(0),s=Object(a.a)({},(function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[r("h1",{attrs:{id:"examples"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#examples"}},[e._v("#")]),e._v(" Examples")]),e._v(" "),r("p",[e._v("A sample project showing how to serve a simple GraphQL schema over HTTP and WebSocket using "),r("a",{attrs:{href:"https://github.com/http4s/http4s",target:"_blank",rel:"noopener noreferrer"}},[e._v("http4s"),r("OutboundLink")],1),e._v(" is available in the "),r("a",{attrs:{href:"https://github.com/ghostdogpr/caliban/tree/master/examples/",target:"_blank",rel:"noopener noreferrer"}},[e._v("examples"),r("OutboundLink")],1),e._v(" folder.")])])}),[],!1,null,null,null);t.default=s.exports}}]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{209:function(e,t,r){"use strict";r.r(t);var a=r(0),s=Object(a.a)({},(function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[r("h1",{attrs:{id:"examples"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#examples"}},[e._v("#")]),e._v(" Examples")]),e._v(" "),r("p",[e._v("A sample project showing how to serve a simple GraphQL schema over HTTP and WebSocket using "),r("a",{attrs:{href:"https://github.com/http4s/http4s",target:"_blank",rel:"noopener noreferrer"}},[e._v("http4s"),r("OutboundLink")],1),e._v(" is available in the "),r("a",{attrs:{href:"https://github.com/ghostdogpr/caliban/tree/master/examples/",target:"_blank",rel:"noopener noreferrer"}},[e._v("examples"),r("OutboundLink")],1),e._v(" folder.")])])}),[],!1,null,null,null);t.default=s.exports}}]); \ No newline at end of file diff --git a/docs/assets/js/9.4503481a.js b/docs/assets/js/9.4503481a.js deleted file mode 100644 index 6fdc16fce..000000000 --- a/docs/assets/js/9.4503481a.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[9],{209:function(t,e,r){"use strict";r.r(e);var n=r(0),a=Object(n.a)({},(function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[r("h1",{attrs:{id:"introspection"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#introspection"}},[t._v("#")]),t._v(" Introspection")]),t._v(" "),r("p",[t._v("Introspection queries are fully supported, which means you can use your favorite tool to inspect your schema and generate documentation for free.")]),t._v(" "),r("p",[t._v("Here's an example of documentation generated by introspection in "),r("a",{attrs:{href:"https://altair.sirmuel.design/",target:"_blank",rel:"noopener noreferrer"}},[t._v("Altair GraphQL Client"),r("OutboundLink")],1),t._v(":")]),t._v(" "),r("p",[r("img",{attrs:{src:"/caliban/altair.png",alt:"altair screenshot"}})])])}),[],!1,null,null,null);e.default=a.exports}}]); \ No newline at end of file diff --git a/docs/assets/js/9.8c01b08f.js b/docs/assets/js/9.8c01b08f.js new file mode 100644 index 000000000..9a8520d3f --- /dev/null +++ b/docs/assets/js/9.8c01b08f.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[9],{208:function(t,a,s){"use strict";s.r(a);var n=s(0),e=Object(n.a)({},(function(){var t=this,a=t.$createElement,s=t._self._c||a;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"interop-cats"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#interop-cats"}},[t._v("#")]),t._v(" Interop (Cats)")]),t._v(" "),s("p",[t._v("If you prefer using "),s("a",{attrs:{href:"https://github.com/monix/monix",target:"_blank",rel:"noopener noreferrer"}},[t._v("Monix"),s("OutboundLink")],1),t._v(" or "),s("a",{attrs:{href:"https://github.com/typelevel/cats-effect",target:"_blank",rel:"noopener noreferrer"}},[t._v("Cats IO"),s("OutboundLink")],1),t._v(" rather than ZIO, you can use the "),s("code",[t._v("caliban-cats")]),t._v(" module.")]),t._v(" "),s("p",[t._v("You first need to import "),s("code",[t._v("caliban.interop.cats.implicits._")]),t._v(" and have an implicit "),s("code",[t._v("zio.Runtime")]),t._v(" in scope. Then a few helpers are available:")]),t._v(" "),s("ul",[s("li",[t._v("the GraphQL object is enriched with "),s("code",[t._v("executeAsync")]),t._v(" and "),s("code",[t._v("checkAsync")]),t._v(", variants of "),s("code",[t._v("execute")]),t._v(" and "),s("code",[t._v("check")]),t._v(" that return an "),s("code",[t._v("F[_]: Async")]),t._v(" instead of a "),s("code",[t._v("ZIO")]),t._v(".")]),t._v(" "),s("li",[t._v("the "),s("code",[t._v("Http4sAdapter")]),t._v(" also has cats-effect variants named "),s("code",[t._v("makeRestServiceF")]),t._v(" and "),s("code",[t._v("makeWebSocketServiceF")]),t._v(".")])]),t._v(" "),s("p",[t._v("In addition to that, a "),s("code",[t._v("Schema")]),t._v(" for any "),s("code",[t._v("F[_]: Effect")]),t._v(" is provided. That means you can include fields returning Monix Task for Cats IO in your queries, mutations or subscriptions.")]),t._v(" "),s("p",[t._v("The following example shows how to create an interpreter and run a query while only using Cats IO.")]),t._v(" "),s("div",{staticClass:"language-scala extra-class"},[s("pre",{pre:!0,attrs:{class:"language-scala"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("GraphQL"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("graphQL\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("RootResolver\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token namespace"}},[t._v("caliban"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("interop"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("cats"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("implicits")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("_\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token namespace"}},[t._v("cats"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("effect")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v(" ExitCode"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" IO"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" IOApp "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("import")]),t._v(" zio"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("DefaultRuntime\n\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("object")]),t._v(" ExampleCatsInterop "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("extends")]),t._v(" IOApp "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("implicit")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" runtime "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" DefaultRuntime "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("case")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" Queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("numbers"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" List"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Int")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" randomNumber"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" IO"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("Int")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" queries "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" Queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("List"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("4")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" IO"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("scala"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("util"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("Random"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("nextInt"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" interpreter "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" graphQL"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("RootResolver"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("queries"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("val")]),t._v(" query "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"""\n {\n numbers\n randomNumber\n }"""')]),t._v("\n\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("override")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("def")]),t._v(" run"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("args"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" List"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),s("span",{pre:!0,attrs:{class:"token builtin"}},[t._v("String")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" IO"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("ExitCode"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("for")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n result "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("<-")]),t._v(" interpreter"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("executeAsync"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("IO"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("query"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n _ "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("<-")]),t._v(" IO"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("println"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("result"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("yield")]),t._v(" ExitCode"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("Success\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),s("p",[t._v("You can find this example within the "),s("a",{attrs:{href:"https://github.com/ghostdogpr/caliban/blob/master/examples/src/main/scala/caliban/interop/cats/ExampleCatsInterop.scala",target:"_blank",rel:"noopener noreferrer"}},[t._v("examples"),s("OutboundLink")],1),t._v(" project.")])])}),[],!1,null,null,null);a.default=e.exports}}]); \ No newline at end of file diff --git a/docs/assets/js/app.f3d882e0.js b/docs/assets/js/app.aec65cd6.js similarity index 86% rename from docs/assets/js/app.f3d882e0.js rename to docs/assets/js/app.aec65cd6.js index e7164811b..55555733c 100644 --- a/docs/assets/js/app.f3d882e0.js +++ b/docs/assets/js/app.aec65cd6.js @@ -1,6 +1,6 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[0],[]]);!function(t){function e(e){for(var r,a,s=e[0],c=e[1],u=e[2],f=0,p=[];f
'};function o(t,e,n){return tn?n:t}function i(t){return 100*(-1+t)}n.configure=function(t){var e,n;for(e in t)void 0!==(n=t[e])&&t.hasOwnProperty(e)&&(r[e]=n);return this},n.status=null,n.set=function(t){var e=n.isStarted();t=o(t,r.minimum,1),n.status=1===t?null:t;var c=n.render(!e),u=c.querySelector(r.barSelector),l=r.speed,f=r.easing;return c.offsetWidth,a((function(e){""===r.positionUsing&&(r.positionUsing=n.getPositioningCSS()),s(u,function(t,e,n){var o;return(o="translate3d"===r.positionUsing?{transform:"translate3d("+i(t)+"%,0,0)"}:"translate"===r.positionUsing?{transform:"translate("+i(t)+"%,0)"}:{"margin-left":i(t)+"%"}).transition="all "+e+"ms "+n,o}(t,l,f)),1===t?(s(c,{transition:"none",opacity:1}),c.offsetWidth,setTimeout((function(){s(c,{transition:"all "+l+"ms linear",opacity:0}),setTimeout((function(){n.remove(),e()}),l)}),l)):setTimeout(e,l)})),this},n.isStarted=function(){return"number"==typeof n.status},n.start=function(){n.status||n.set(0);var t=function(){setTimeout((function(){n.status&&(n.trickle(),t())}),r.trickleSpeed)};return r.trickle&&t(),this},n.done=function(t){return t||n.status?n.inc(.3+.5*Math.random()).set(1):this},n.inc=function(t){var e=n.status;return e?("number"!=typeof t&&(t=(1-e)*o(Math.random()*e,.1,.95)),e=o(e+t,0,.994),n.set(e)):n.start()},n.trickle=function(){return n.inc(Math.random()*r.trickleRate)},t=0,e=0,n.promise=function(r){return r&&"resolved"!==r.state()?(0===e&&n.start(),t++,e++,r.always((function(){0==--e?(t=0,n.done()):n.set((t-e)/t)})),this):this},n.render=function(t){if(n.isRendered())return document.getElementById("nprogress");u(document.documentElement,"nprogress-busy");var e=document.createElement("div");e.id="nprogress",e.innerHTML=r.template;var o,a=e.querySelector(r.barSelector),c=t?"-100":i(n.status||0),l=document.querySelector(r.parent);return s(a,{transition:"all 0 linear",transform:"translate3d("+c+"%,0,0)"}),r.showSpinner||(o=e.querySelector(r.spinnerSelector))&&p(o),l!=document.body&&u(l,"nprogress-custom-parent"),l.appendChild(e),e},n.remove=function(){l(document.documentElement,"nprogress-busy"),l(document.querySelector(r.parent),"nprogress-custom-parent");var t=document.getElementById("nprogress");t&&p(t)},n.isRendered=function(){return!!document.getElementById("nprogress")},n.getPositioningCSS=function(){var t=document.body.style,e="WebkitTransform"in t?"Webkit":"MozTransform"in t?"Moz":"msTransform"in t?"ms":"OTransform"in t?"O":"";return e+"Perspective"in t?"translate3d":e+"Transform"in t?"translate":"margin"};var a=function(){var t=[];function e(){var n=t.shift();n&&n(e)}return function(n){t.push(n),1==t.length&&e()}}(),s=function(){var t=["Webkit","O","Moz","ms"],e={};function n(n){return n=n.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,(function(t,e){return e.toUpperCase()})),e[n]||(e[n]=function(e){var n=document.body.style;if(e in n)return e;for(var r,o=t.length,i=e.charAt(0).toUpperCase()+e.slice(1);o--;)if((r=t[o]+i)in n)return r;return e}(n))}function r(t,e,r){e=n(e),t.style[e]=r}return function(t,e){var n,o,i=arguments;if(2==i.length)for(n in e)void 0!==(o=e[n])&&e.hasOwnProperty(n)&&r(t,n,o);else r(t,i[1],i[2])}}();function c(t,e){return("string"==typeof t?t:f(t)).indexOf(" "+e+" ")>=0}function u(t,e){var n=f(t),r=n+e;c(n,e)||(t.className=r.substring(1))}function l(t,e){var n,r=f(t);c(t,e)&&(n=r.replace(" "+e+" "," "),t.className=n.substring(1,n.length-1))}function f(t){return(" "+(t.className||"")+" ").replace(/\s+/gi," ")}function p(t){t&&t.parentNode&&t.parentNode.removeChild(t)}return n})?r.call(e,n,e,t):r)||(t.exports=o)},function(t,e){var n="Expected a function",r=NaN,o="[object Symbol]",i=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt,l="object"==typeof global&&global&&global.Object===Object&&global,f="object"==typeof self&&self&&self.Object===Object&&self,p=l||f||Function("return this")(),d=Object.prototype.toString,h=Math.max,v=Math.min,m=function(){return p.Date.now()};function y(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function g(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&d.call(t)==o}(t))return r;if(y(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=y(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(i,"");var n=s.test(t);return n||c.test(t)?u(t.slice(2),n?2:8):a.test(t)?r:+t}t.exports=function(t,e,r){var o,i,a,s,c,u,l=0,f=!1,p=!1,d=!0;if("function"!=typeof t)throw new TypeError(n);function b(e){var n=o,r=i;return o=i=void 0,l=e,s=t.apply(r,n)}function _(t){var n=t-u;return void 0===u||n>=e||n<0||p&&t-l>=a}function w(){var t=m();if(_(t))return $(t);c=setTimeout(w,function(t){var n=e-(t-u);return p?v(n,a-(t-l)):n}(t))}function $(t){return c=void 0,d&&o?b(t):(o=i=void 0,s)}function C(){var t=m(),n=_(t);if(o=arguments,i=this,u=t,n){if(void 0===c)return function(t){return l=t,c=setTimeout(w,e),f?b(t):s}(u);if(p)return c=setTimeout(w,e),b(u)}return void 0===c&&(c=setTimeout(w,e)),s}return e=g(e)||0,y(r)&&(f=!!r.leading,a=(p="maxWait"in r)?h(g(r.maxWait)||0,e):a,d="trailing"in r?!!r.trailing:d),C.cancel=function(){void 0!==c&&clearTimeout(c),l=0,o=u=i=c=void 0},C.flush=function(){return void 0===c?s:$(m())},C}},function(t,e,n){t.exports=n(8)},function(t,e,n){Promise.all([n.e(0),n.e(12)]).then(n.t.bind(null,9,7))},function(t,e,n){},function(t,e,n){"use strict";var r=n(1);n.n(r).a},function(t,e,n){"use strict";n.r(e); + * @license MIT */void 0===(o="function"==typeof(r=function(){var t,e,n={version:"0.2.0"},r=n.settings={minimum:.08,easing:"ease",positionUsing:"",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'
'};function o(t,e,n){return tn?n:t}function i(t){return 100*(-1+t)}n.configure=function(t){var e,n;for(e in t)void 0!==(n=t[e])&&t.hasOwnProperty(e)&&(r[e]=n);return this},n.status=null,n.set=function(t){var e=n.isStarted();t=o(t,r.minimum,1),n.status=1===t?null:t;var c=n.render(!e),u=c.querySelector(r.barSelector),l=r.speed,f=r.easing;return c.offsetWidth,a((function(e){""===r.positionUsing&&(r.positionUsing=n.getPositioningCSS()),s(u,function(t,e,n){var o;return(o="translate3d"===r.positionUsing?{transform:"translate3d("+i(t)+"%,0,0)"}:"translate"===r.positionUsing?{transform:"translate("+i(t)+"%,0)"}:{"margin-left":i(t)+"%"}).transition="all "+e+"ms "+n,o}(t,l,f)),1===t?(s(c,{transition:"none",opacity:1}),c.offsetWidth,setTimeout((function(){s(c,{transition:"all "+l+"ms linear",opacity:0}),setTimeout((function(){n.remove(),e()}),l)}),l)):setTimeout(e,l)})),this},n.isStarted=function(){return"number"==typeof n.status},n.start=function(){n.status||n.set(0);var t=function(){setTimeout((function(){n.status&&(n.trickle(),t())}),r.trickleSpeed)};return r.trickle&&t(),this},n.done=function(t){return t||n.status?n.inc(.3+.5*Math.random()).set(1):this},n.inc=function(t){var e=n.status;return e?("number"!=typeof t&&(t=(1-e)*o(Math.random()*e,.1,.95)),e=o(e+t,0,.994),n.set(e)):n.start()},n.trickle=function(){return n.inc(Math.random()*r.trickleRate)},t=0,e=0,n.promise=function(r){return r&&"resolved"!==r.state()?(0===e&&n.start(),t++,e++,r.always((function(){0==--e?(t=0,n.done()):n.set((t-e)/t)})),this):this},n.render=function(t){if(n.isRendered())return document.getElementById("nprogress");u(document.documentElement,"nprogress-busy");var e=document.createElement("div");e.id="nprogress",e.innerHTML=r.template;var o,a=e.querySelector(r.barSelector),c=t?"-100":i(n.status||0),l=document.querySelector(r.parent);return s(a,{transition:"all 0 linear",transform:"translate3d("+c+"%,0,0)"}),r.showSpinner||(o=e.querySelector(r.spinnerSelector))&&p(o),l!=document.body&&u(l,"nprogress-custom-parent"),l.appendChild(e),e},n.remove=function(){l(document.documentElement,"nprogress-busy"),l(document.querySelector(r.parent),"nprogress-custom-parent");var t=document.getElementById("nprogress");t&&p(t)},n.isRendered=function(){return!!document.getElementById("nprogress")},n.getPositioningCSS=function(){var t=document.body.style,e="WebkitTransform"in t?"Webkit":"MozTransform"in t?"Moz":"msTransform"in t?"ms":"OTransform"in t?"O":"";return e+"Perspective"in t?"translate3d":e+"Transform"in t?"translate":"margin"};var a=function(){var t=[];function e(){var n=t.shift();n&&n(e)}return function(n){t.push(n),1==t.length&&e()}}(),s=function(){var t=["Webkit","O","Moz","ms"],e={};function n(n){return n=n.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,(function(t,e){return e.toUpperCase()})),e[n]||(e[n]=function(e){var n=document.body.style;if(e in n)return e;for(var r,o=t.length,i=e.charAt(0).toUpperCase()+e.slice(1);o--;)if((r=t[o]+i)in n)return r;return e}(n))}function r(t,e,r){e=n(e),t.style[e]=r}return function(t,e){var n,o,i=arguments;if(2==i.length)for(n in e)void 0!==(o=e[n])&&e.hasOwnProperty(n)&&r(t,n,o);else r(t,i[1],i[2])}}();function c(t,e){return("string"==typeof t?t:f(t)).indexOf(" "+e+" ")>=0}function u(t,e){var n=f(t),r=n+e;c(n,e)||(t.className=r.substring(1))}function l(t,e){var n,r=f(t);c(t,e)&&(n=r.replace(" "+e+" "," "),t.className=n.substring(1,n.length-1))}function f(t){return(" "+(t.className||"")+" ").replace(/\s+/gi," ")}function p(t){t&&t.parentNode&&t.parentNode.removeChild(t)}return n})?r.call(e,n,e,t):r)||(t.exports=o)},function(t,e){var n="Expected a function",r=NaN,o="[object Symbol]",i=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt,l="object"==typeof global&&global&&global.Object===Object&&global,f="object"==typeof self&&self&&self.Object===Object&&self,p=l||f||Function("return this")(),d=Object.prototype.toString,h=Math.max,v=Math.min,m=function(){return p.Date.now()};function y(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function g(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&d.call(t)==o}(t))return r;if(y(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=y(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(i,"");var n=s.test(t);return n||c.test(t)?u(t.slice(2),n?2:8):a.test(t)?r:+t}t.exports=function(t,e,r){var o,i,a,s,c,u,l=0,f=!1,p=!1,d=!0;if("function"!=typeof t)throw new TypeError(n);function b(e){var n=o,r=i;return o=i=void 0,l=e,s=t.apply(r,n)}function _(t){var n=t-u;return void 0===u||n>=e||n<0||p&&t-l>=a}function w(){var t=m();if(_(t))return $(t);c=setTimeout(w,function(t){var n=e-(t-u);return p?v(n,a-(t-l)):n}(t))}function $(t){return c=void 0,d&&o?b(t):(o=i=void 0,s)}function C(){var t=m(),n=_(t);if(o=arguments,i=this,u=t,n){if(void 0===c)return function(t){return l=t,c=setTimeout(w,e),f?b(t):s}(u);if(p)return c=setTimeout(w,e),b(u)}return void 0===c&&(c=setTimeout(w,e)),s}return e=g(e)||0,y(r)&&(f=!!r.leading,a=(p="maxWait"in r)?h(g(r.maxWait)||0,e):a,d="trailing"in r?!!r.trailing:d),C.cancel=function(){void 0!==c&&clearTimeout(c),l=0,o=u=i=c=void 0},C.flush=function(){return void 0===c?s:$(m())},C}},function(t,e,n){t.exports=n(8)},function(t,e,n){Promise.all([n.e(0),n.e(13)]).then(n.t.bind(null,9,7))},function(t,e,n){},function(t,e,n){"use strict";var r=n(1);n.n(r).a},function(t,e,n){"use strict";n.r(e); /*! * Vue.js v2.6.10 * (c) 2014-2019 Evan You @@ -11,4 +11,4 @@ var r=Object.freeze({});function o(t){return null==t}function i(t){return null!= * vue-router v3.1.3 * (c) 2019 Evan You * @license MIT - */function Fo(t){return Object.prototype.toString.call(t).indexOf("Error")>-1}function Bo(t,e){return e instanceof t||e&&(e.name===t.name||e._name===t._name)}function Vo(t,e){for(var n in e)t[n]=e[n];return t}var qo={name:"RouterView",functional:!0,props:{name:{type:String,default:"default"}},render:function(t,e){var n=e.props,r=e.children,o=e.parent,i=e.data;i.routerView=!0;for(var a=o.$createElement,s=n.name,c=o.$route,u=o._routerViewCache||(o._routerViewCache={}),l=0,f=!1;o&&o._routerRoot!==o;){var p=o.$vnode&&o.$vnode.data;p&&(p.routerView&&l++,p.keepAlive&&o._inactive&&(f=!0)),o=o.$parent}if(i.routerViewDepth=l,f)return a(u[s],i,r);var d=c.matched[l];if(!d)return u[s]=null,a();var h=u[s]=d.components[s];i.registerRouteInstance=function(t,e){var n=d.instances[s];(e&&n!==t||!e&&n===t)&&(d.instances[s]=e)},(i.hook||(i.hook={})).prepatch=function(t,e){d.instances[s]=e.componentInstance},i.hook.init=function(t){t.data.keepAlive&&t.componentInstance&&t.componentInstance!==d.instances[s]&&(d.instances[s]=t.componentInstance)};var v=i.props=function(t,e){switch(typeof e){case"undefined":return;case"object":return e;case"function":return e(t);case"boolean":return e?t.params:void 0;default:0}}(c,d.props&&d.props[s]);if(v){v=i.props=Vo({},v);var m=i.attrs=i.attrs||{};for(var y in v)h.props&&y in h.props||(m[y]=v[y],delete v[y])}return a(h,i,r)}};var Ho=/[!'()*]/g,zo=function(t){return"%"+t.charCodeAt(0).toString(16)},Wo=/%2C/g,Ko=function(t){return encodeURIComponent(t).replace(Ho,zo).replace(Wo,",")},Xo=decodeURIComponent;function Go(t){var e={};return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach((function(t){var n=t.replace(/\+/g," ").split("="),r=Xo(n.shift()),o=n.length>0?Xo(n.join("=")):null;void 0===e[r]?e[r]=o:Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]})),e):e}function Jo(t){var e=t?Object.keys(t).map((function(e){var n=t[e];if(void 0===n)return"";if(null===n)return Ko(e);if(Array.isArray(n)){var r=[];return n.forEach((function(t){void 0!==t&&(null===t?r.push(Ko(e)):r.push(Ko(e)+"="+Ko(t)))})),r.join("&")}return Ko(e)+"="+Ko(n)})).filter((function(t){return t.length>0})).join("&"):null;return e?"?"+e:""}var Qo=/\/?$/;function Yo(t,e,n,r){var o=r&&r.options.stringifyQuery,i=e.query||{};try{i=Zo(i)}catch(t){}var a={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:i,params:e.params||{},fullPath:ni(e,o),matched:t?ei(t):[]};return n&&(a.redirectedFrom=ni(n,o)),Object.freeze(a)}function Zo(t){if(Array.isArray(t))return t.map(Zo);if(t&&"object"==typeof t){var e={};for(var n in t)e[n]=Zo(t[n]);return e}return t}var ti=Yo(null,{path:"/"});function ei(t){for(var e=[];t;)e.unshift(t),t=t.parent;return e}function ni(t,e){var n=t.path,r=t.query;void 0===r&&(r={});var o=t.hash;return void 0===o&&(o=""),(n||"/")+(e||Jo)(r)+o}function ri(t,e){return e===ti?t===e:!!e&&(t.path&&e.path?t.path.replace(Qo,"")===e.path.replace(Qo,"")&&t.hash===e.hash&&oi(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&oi(t.query,e.query)&&oi(t.params,e.params)))}function oi(t,e){if(void 0===t&&(t={}),void 0===e&&(e={}),!t||!e)return t===e;var n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every((function(n){var r=t[n],o=e[n];return"object"==typeof r&&"object"==typeof o?oi(r,o):String(r)===String(o)}))}function ii(t,e,n){var r=t.charAt(0);if("/"===r)return t;if("?"===r||"#"===r)return e+t;var o=e.split("/");n&&o[o.length-1]||o.pop();for(var i=t.replace(/^\//,"").split("/"),a=0;a=0&&(e=t.slice(r),t=t.slice(0,r));var o=t.indexOf("?");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{path:t,query:n,hash:e}}(o.path||""),c=e&&e.path||"/",u=s.path?ii(s.path,c,n||o.append):c,l=function(t,e,n){void 0===e&&(e={});var r,o=n||Go;try{r=o(t||"")}catch(t){r={}}for(var i in e)r[i]=e[i];return r}(s.query,o.query,r&&r.options.parseQuery),f=o.hash||s.hash;return f&&"#"!==f.charAt(0)&&(f="#"+f),{_normalized:!0,path:u,query:l,hash:f}}var Ai,Oi=[String,Object],Si=[String,Array],Ei=function(){},ji={name:"RouterLink",props:{to:{type:Oi,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String,exactActiveClass:String,event:{type:Si,default:"click"}},render:function(t){var e=this,n=this.$router,r=this.$route,o=n.resolve(this.to,r,this.append),i=o.location,a=o.route,s=o.href,c={},u=n.options.linkActiveClass,l=n.options.linkExactActiveClass,f=null==u?"router-link-active":u,p=null==l?"router-link-exact-active":l,d=null==this.activeClass?f:this.activeClass,h=null==this.exactActiveClass?p:this.exactActiveClass,v=a.redirectedFrom?Yo(null,ki(a.redirectedFrom),null,n):a;c[h]=ri(r,v),c[d]=this.exact?c[h]:function(t,e){return 0===t.path.replace(Qo,"/").indexOf(e.path.replace(Qo,"/"))&&(!e.hash||t.hash===e.hash)&&function(t,e){for(var n in e)if(!(n in t))return!1;return!0}(t.query,e.query)}(r,v);var m=function(t){Ti(t)&&(e.replace?n.replace(i,Ei):n.push(i,Ei))},y={click:Ti};Array.isArray(this.event)?this.event.forEach((function(t){y[t]=m})):y[this.event]=m;var g={class:c},b=!this.$scopedSlots.$hasNormal&&this.$scopedSlots.default&&this.$scopedSlots.default({href:s,route:a,navigate:m,isActive:c[d],isExactActive:c[h]});if(b){if(1===b.length)return b[0];if(b.length>1||!b.length)return 0===b.length?t():t("span",{},b)}if("a"===this.tag)g.on=y,g.attrs={href:s};else{var _=function t(e){if(e)for(var n,r=0;r-1&&(s.params[p]=n.params[p]);return s.path=xi(l.path,s.params),c(l,s,a)}if(s.path){s.params={};for(var d=0;d=t.length?n():t[o]?e(t[o],(function(){r(o+1)})):r(o+1)};r(0)}function na(t){return function(e,n,r){var o=!1,i=0,a=null;ra(t,(function(t,e,n,s){if("function"==typeof t&&void 0===t.cid){o=!0,i++;var c,u=aa((function(e){var o;((o=e).__esModule||ia&&"Module"===o[Symbol.toStringTag])&&(e=e.default),t.resolved="function"==typeof e?e:Ai.extend(e),n.components[s]=e,--i<=0&&r()})),l=aa((function(t){var e="Failed to resolve async component "+s+": "+t;a||(a=Fo(t)?t:new Error(e),r(a))}));try{c=t(u,l)}catch(t){l(t)}if(c)if("function"==typeof c.then)c.then(u,l);else{var f=c.component;f&&"function"==typeof f.then&&f.then(u,l)}}})),o||r()}}function ra(t,e){return oa(t.map((function(t){return Object.keys(t.components).map((function(n){return e(t.components[n],t.instances[n],t,n)}))})))}function oa(t){return Array.prototype.concat.apply([],t)}var ia="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function aa(t){var e=!1;return function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];if(!e)return e=!0,t.apply(this,n)}}var sa=function(t){function e(e){t.call(this),this.name=this._name="NavigationDuplicated",this.message='Navigating to current location ("'+e.fullPath+'") is not allowed',Object.defineProperty(this,"stack",{value:(new t).stack,writable:!0,configurable:!0})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Error);sa._name="NavigationDuplicated";var ca=function(t,e){this.router=t,this.base=function(t){if(!t)if(Pi){var e=document.querySelector("base");t=(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else t="/";"/"!==t.charAt(0)&&(t="/"+t);return t.replace(/\/$/,"")}(e),this.current=ti,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};function ua(t,e,n,r){var o=ra(t,(function(t,r,o,i){var a=function(t,e){"function"!=typeof t&&(t=Ai.extend(t));return t.options[e]}(t,e);if(a)return Array.isArray(a)?a.map((function(t){return n(t,r,o,i)})):n(a,r,o,i)}));return oa(r?o.reverse():o)}function la(t,e){if(e)return function(){return t.apply(e,arguments)}}ca.prototype.listen=function(t){this.cb=t},ca.prototype.onReady=function(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))},ca.prototype.onError=function(t){this.errorCbs.push(t)},ca.prototype.transitionTo=function(t,e,n){var r=this,o=this.router.match(t,this.current);this.confirmTransition(o,(function(){r.updateRoute(o),e&&e(o),r.ensureURL(),r.ready||(r.ready=!0,r.readyCbs.forEach((function(t){t(o)})))}),(function(t){n&&n(t),t&&!r.ready&&(r.ready=!0,r.readyErrorCbs.forEach((function(e){e(t)})))}))},ca.prototype.confirmTransition=function(t,e,n){var r=this,o=this.current,i=function(t){!Bo(sa,t)&&Fo(t)&&(r.errorCbs.length?r.errorCbs.forEach((function(e){e(t)})):console.error(t)),n&&n(t)};if(ri(t,o)&&t.matched.length===o.matched.length)return this.ensureURL(),i(new sa(t));var a=function(t,e){var n,r=Math.max(t.length,e.length);for(n=0;n-1?decodeURI(t.slice(0,r))+t.slice(r):decodeURI(t)}else n>-1&&(t=decodeURI(t.slice(0,n))+t.slice(n));return t}function ma(t){var e=window.location.href,n=e.indexOf("#");return(n>=0?e.slice(0,n):e)+"#"+t}function ya(t){Yi?Zi(ma(t)):window.location.hash=t}function ga(t){Yi?ta(ma(t)):window.location.replace(ma(t))}var ba=function(t){function e(e,n){t.call(this,e,n),this.stack=[],this.index=-1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.push=function(t,e,n){var r=this;this.transitionTo(t,(function(t){r.stack=r.stack.slice(0,r.index+1).concat(t),r.index++,e&&e(t)}),n)},e.prototype.replace=function(t,e,n){var r=this;this.transitionTo(t,(function(t){r.stack=r.stack.slice(0,r.index).concat(t),e&&e(t)}),n)},e.prototype.go=function(t){var e=this,n=this.index+t;if(!(n<0||n>=this.stack.length)){var r=this.stack[n];this.confirmTransition(r,(function(){e.index=n,e.updateRoute(r)}),(function(t){Bo(sa,t)&&(e.index=n)}))}},e.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},e.prototype.ensureURL=function(){},e}(ca),_a=function(t){void 0===t&&(t={}),this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=Ii(t.routes||[],this);var e=t.mode||"hash";switch(this.fallback="history"===e&&!Yi&&!1!==t.fallback,this.fallback&&(e="hash"),Pi||(e="abstract"),this.mode=e,e){case"history":this.history=new fa(this,t.base);break;case"hash":this.history=new da(this,t.base,this.fallback);break;case"abstract":this.history=new ba(this,t.base);break;default:0}},wa={currentRoute:{configurable:!0}};function $a(t,e){return t.push(e),function(){var n=t.indexOf(e);n>-1&&t.splice(n,1)}}_a.prototype.match=function(t,e,n){return this.matcher.match(t,e,n)},wa.currentRoute.get=function(){return this.history&&this.history.current},_a.prototype.init=function(t){var e=this;if(this.apps.push(t),t.$once("hook:destroyed",(function(){var n=e.apps.indexOf(t);n>-1&&e.apps.splice(n,1),e.app===t&&(e.app=e.apps[0]||null)})),!this.app){this.app=t;var n=this.history;if(n instanceof fa)n.transitionTo(n.getCurrentLocation());else if(n instanceof da){var r=function(){n.setupListeners()};n.transitionTo(n.getCurrentLocation(),r,r)}n.listen((function(t){e.apps.forEach((function(e){e._route=t}))}))}},_a.prototype.beforeEach=function(t){return $a(this.beforeHooks,t)},_a.prototype.beforeResolve=function(t){return $a(this.resolveHooks,t)},_a.prototype.afterEach=function(t){return $a(this.afterHooks,t)},_a.prototype.onReady=function(t,e){this.history.onReady(t,e)},_a.prototype.onError=function(t){this.history.onError(t)},_a.prototype.push=function(t,e,n){var r=this;if(!e&&!n&&"undefined"!=typeof Promise)return new Promise((function(e,n){r.history.push(t,e,n)}));this.history.push(t,e,n)},_a.prototype.replace=function(t,e,n){var r=this;if(!e&&!n&&"undefined"!=typeof Promise)return new Promise((function(e,n){r.history.replace(t,e,n)}));this.history.replace(t,e,n)},_a.prototype.go=function(t){this.history.go(t)},_a.prototype.back=function(){this.go(-1)},_a.prototype.forward=function(){this.go(1)},_a.prototype.getMatchedComponents=function(t){var e=t?t.matched?t:this.resolve(t).route:this.currentRoute;return e?[].concat.apply([],e.matched.map((function(t){return Object.keys(t.components).map((function(e){return t.components[e]}))}))):[]},_a.prototype.resolve=function(t,e,n){var r=ki(t,e=e||this.history.current,n,this),o=this.match(r,e),i=o.redirectedFrom||o.fullPath;return{location:r,route:o,href:function(t,e,n){var r="hash"===n?"#"+e:e;return t?ai(t+"/"+r):r}(this.history.base,i,this.mode),normalizedTo:r,resolved:o}},_a.prototype.addRoutes=function(t){this.matcher.addRoutes(t),this.history.current!==ti&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(_a.prototype,wa),_a.install=function t(e){if(!t.installed||Ai!==e){t.installed=!0,Ai=e;var n=function(t){return void 0!==t},r=function(t,e){var r=t.$options._parentVnode;n(r)&&n(r=r.data)&&n(r=r.registerRouteInstance)&&r(t,e)};e.mixin({beforeCreate:function(){n(this.$options.router)?(this._routerRoot=this,this._router=this.$options.router,this._router.init(this),e.util.defineReactive(this,"_route",this._router.history.current)):this._routerRoot=this.$parent&&this.$parent._routerRoot||this,r(this,this)},destroyed:function(){r(this)}}),Object.defineProperty(e.prototype,"$router",{get:function(){return this._routerRoot._router}}),Object.defineProperty(e.prototype,"$route",{get:function(){return this._routerRoot._route}}),e.component("RouterView",qo),e.component("RouterLink",ji);var o=e.config.optionMergeStrategies;o.beforeRouteEnter=o.beforeRouteLeave=o.beforeRouteUpdate=o.created}},_a.version="3.1.3",Pi&&window.Vue&&window.Vue.use(_a);var Ca=_a;var xa={NotFound:()=>n.e(4).then(n.bind(null,204)),Layout:()=>Promise.all([n.e(0),n.e(2)]).then(n.bind(null,203))},ka={"v-3c88bbf2":()=>n.e(5).then(n.bind(null,205)),"v-0decf914":()=>n.e(6).then(n.bind(null,206)),"v-d7e5bcfc":()=>n.e(7).then(n.bind(null,207)),"v-4419f5c9":()=>n.e(8).then(n.bind(null,208)),"v-70457f72":()=>n.e(9).then(n.bind(null,209)),"v-7bafdcee":()=>n.e(10).then(n.bind(null,210)),"v-300a59ee":()=>n.e(11).then(n.bind(null,211))};function Aa(t){const e=Object.create(null);return function(n){return e[n]||(e[n]=t(n))}}const Oa=/-(\w)/g,Sa=Aa(t=>t.replace(Oa,(t,e)=>e?e.toUpperCase():"")),Ea=/\B([A-Z])/g,ja=Aa(t=>t.replace(Ea,"-$1").toLowerCase()),Ta=Aa(t=>t.charAt(0).toUpperCase()+t.slice(1));function Pa(t,e){if(!e)return;if(t(e))return t(e);return e.includes("-")?t(Ta(Sa(e))):t(Ta(e))||t(ja(e))}const Ra=Object.assign({},xa,ka),La=t=>Ra[t],Ia=t=>ka[t],Ma=t=>xa[t],Da=t=>Uo.component(t);function Na(t){return Pa(Ia,t)}function Ua(t){return Pa(Ma,t)}function Fa(t){return Pa(La,t)}function Ba(t){return Pa(Da,t)}function Va(...t){return Promise.all(t.filter(t=>t).map(async t=>{if(!Ba(t)&&Fa(t)){const e=await Fa(t)();Uo.component(t,e.default)}}))}function qa(t,e){"undefined"!=typeof window&&window.__VUEPRESS__&&(window.__VUEPRESS__[t]=e)}var Ha={created(){this.$ssrContext&&(this.$ssrContext.title=this.$title,this.$ssrContext.lang=this.$lang,this.$ssrContext.description=this.$page.description||this.$description)},mounted(){this.currentMetaTags=new Set,this.updateMeta()},methods:{updateMeta(){document.title=this.$title,document.documentElement.lang=this.$lang;const t=this.$page.frontmatter.meta||[],e=t.slice(0);0===t.filter(t=>"description"===t.name).length&&e.push({name:"description",content:this.$description});const n=document.querySelectorAll('meta[name="description"]');n.length&&n.forEach(t=>this.currentMetaTags.add(t)),this.currentMetaTags=new Set(za(e,this.currentMetaTags))}},watch:{$page(){this.updateMeta()}},beforeDestroy(){za(null,this.currentMetaTags)}};function za(t,e){if(e&&[...e].forEach(t=>{document.head.removeChild(t)}),t)return t.map(t=>{const e=document.createElement("meta");return Object.keys(t).forEach(n=>{e.setAttribute(n,t[n])}),document.head.appendChild(e),e})}var Wa=n(3),Ka={mounted(){window.addEventListener("scroll",this.onScroll)},methods:{onScroll:n.n(Wa)()((function(){this.setActiveHash()}),300),setActiveHash(){const t=[].slice.call(document.querySelectorAll(".sidebar-link")),e=[].slice.call(document.querySelectorAll(".header-anchor")).filter(e=>t.some(t=>t.hash===e.hash)),n=Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop),r=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),o=window.innerHeight+n;for(let t=0;t=i.parentElement.offsetTop+10&&(!a||n{this.$nextTick(()=>{this.$vuepress.$set("disableScrollBehavior",!1)})})}}}},beforeDestroy(){window.removeEventListener("scroll",this.onScroll)}},Xa=n(2),Ga=n.n(Xa),Ja=[Ha,Ka,{mounted(){Ga.a.configure({showSpinner:!1}),this.$router.beforeEach((t,e,n)=>{t.path===e.path||Uo.component(t.name)||Ga.a.start(),n()}),this.$router.afterEach(()=>{Ga.a.done(),this.isSidebarOpen=!1})}}],Qa={methods:{getLayout:function(){if(this.$page.path){var t=this.$page.frontmatter.layout;return t&&(this.$vuepress.getLayoutAsyncComponent(t)||this.$vuepress.getVueComponent(t))?t:"Layout"}return"NotFound"}},computed:{layout:function(){var t=this.getLayout();return qa("layout",t),Uo.component(t)}}},Ya=n(0),Za=Object(Ya.a)(Qa,(function(){var t=this.$createElement;return(this._self._c||t)(this.layout,{tag:"component"})}),[],!1,null,null,null).exports;!function(t,e,n){switch(e){case"components":t[e]||(t[e]={}),Object.assign(t[e],n);break;case"mixins":t[e]||(t[e]=[]),t[e].push(...n);break;default:throw new Error("Unknown option name.")}}(Za,"mixins",Ja);const ts=[{name:"v-3c88bbf2",path:"/",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-3c88bbf2").then(n)}},{path:"/index.html",redirect:"/"},{name:"v-0decf914",path:"/about/",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-0decf914").then(n)}},{path:"/about/index.html",redirect:"/about/"},{name:"v-d7e5bcfc",path:"/docs/",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-d7e5bcfc").then(n)}},{path:"/docs/index.html",redirect:"/docs/"},{name:"v-4419f5c9",path:"/docs/examples.html",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-4419f5c9").then(n)}},{name:"v-70457f72",path:"/docs/introspection.html",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-70457f72").then(n)}},{name:"v-7bafdcee",path:"/docs/schema.html",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-7bafdcee").then(n)}},{name:"v-300a59ee",path:"/docs/validation.html",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-300a59ee").then(n)}},{path:"*",component:Za}],es={title:"",description:"",base:"/caliban/",pages:[{title:"Home",frontmatter:{home:!0,heroImage:"/caliban.svg",actionText:"Get Started →",actionLink:"/docs/",features:[{title:"Purely functional",details:"All interfaces are pure and types are referentially transparent."},{title:"Minimal boilerplate",details:"No need to manually define a schema for every type in your API."},{title:"Type safe schema",details:"Schema is derived at compile-time. Resolver is provided at runtime."}]},regularPath:"/",relativePath:"README.md",key:"v-3c88bbf2",path:"/"},{title:"About",frontmatter:{},regularPath:"/about/",relativePath:"about/README.md",key:"v-0decf914",path:"/about/"},{title:"Getting Started",frontmatter:{},regularPath:"/docs/",relativePath:"docs/README.md",key:"v-d7e5bcfc",path:"/docs/",headers:[{level:2,title:"Dependencies",slug:"dependencies"},{level:2,title:"A simple example",slug:"a-simple-example"},{level:2,title:"Mutations",slug:"mutations"},{level:2,title:"Subscriptions",slug:"subscriptions"}]},{title:"Examples",frontmatter:{},regularPath:"/docs/examples.html",relativePath:"docs/examples.md",key:"v-4419f5c9",path:"/docs/examples.html"},{title:"Introspection",frontmatter:{},regularPath:"/docs/introspection.html",relativePath:"docs/introspection.md",key:"v-70457f72",path:"/docs/introspection.html"},{title:"Schemas",frontmatter:{},regularPath:"/docs/schema.html",relativePath:"docs/schema.md",key:"v-7bafdcee",path:"/docs/schema.html",headers:[{level:2,title:"Enum and union",slug:"enum-and-union"},{level:2,title:"Arguments",slug:"arguments"},{level:2,title:"Effects",slug:"effects"},{level:2,title:"Annotations",slug:"annotations"},{level:2,title:"Custom types",slug:"custom-types"}]},{title:"Validation",frontmatter:{},regularPath:"/docs/validation.html",relativePath:"docs/validation.md",key:"v-300a59ee",path:"/docs/validation.html"}],themeConfig:{logo:"/caliban.svg",locales:{"/":{selectText:"Language",label:"English",nav:[{text:"Documentation",link:"/docs/"},{text:"About",link:"/about/"},{text:"Github",link:"https://github.com/ghostdogpr/caliban"},{text:"Scaladoc",link:"https://javadoc.io/doc/com.github.ghostdogpr/caliban_2.12/"}],sidebar:{"/docs/":[{title:"Caliban",collapsable:!1,sidebarDepth:2,children:["","schema","validation","introspection","examples"]}]}}}},locales:{"/":{lang:"en-US",title:"Caliban",description:"Functional GraphQL backend in Scala",path:"/"}}};n(5);Uo.component("Badge",()=>Promise.all([n.e(0),n.e(3)]).then(n.bind(null,212)));n(6);var ns=[{},({Vue:t})=>{t.mixin({computed:{$dataBlock(){return this.$options.__data__block__}}})},{},{}],rs=[];class os{constructor(){this.store=new Uo({data:{state:{}}})}$get(t){return this.store.state[t]}$set(t,e){Uo.set(this.store.state,t,e)}$emit(...t){this.store.$emit(...t)}$on(...t){this.store.$on(...t)}}class is extends os{}Object.assign(is.prototype,{getPageAsyncComponent:Na,getLayoutAsyncComponent:Ua,getAsyncComponent:Fa,getVueComponent:Ba});var as={install(t){const e=new is;t.$vuepress=e,t.prototype.$vuepress=e}};function ss(t,e){return t.options.routes.filter(t=>t.path.toLowerCase()===e.toLowerCase()).length>0}var cs={props:{pageKey:String,slotKey:{type:String,default:"default"}},render(t){const e=this.pageKey||this.$parent.$page.key;return qa("pageKey",e),Uo.component(e)||Uo.component(e,Na(e)),Uo.component(e)?t(e):t("")}},us={functional:!0,props:{slotKey:String,required:!0},render:(t,{props:e,slots:n})=>t("div",{class:[`content__${e.slotKey}`]},n()[e.slotKey])},ls=(n(7),Object(Ya.a)({},(function(t,e){var n=e._c;return n("svg",{staticClass:"icon outbound",attrs:{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",x:"0px",y:"0px",viewBox:"0 0 100 100",width:"15",height:"15"}},[n("path",{attrs:{fill:"currentColor",d:"M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"}}),e._v(" "),n("polygon",{attrs:{fill:"currentColor",points:"45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"}})])}),[],!0,null,null,null).exports),fs={functional:!0,render(t,{parent:e,children:n}){if(e._isMounted)return n;e.$once("hook:mounted",()=>{e.$forceUpdate()})}};Uo.config.productionTip=!1,Uo.use(Ca),Uo.use(as),Uo.mixin(function(t,e,n=Uo){!function(t){t.locales&&Object.keys(t.locales).forEach(e=>{t.locales[e].path=e});Object.freeze(t)}(e),n.$vuepress.$set("siteData",e);const r=new(t(n.$vuepress.$get("siteData"))),o=Object.getOwnPropertyDescriptors(Object.getPrototypeOf(r)),i={};return Object.keys(o).reduce((t,e)=>(e.startsWith("$")&&(t[e]=o[e].get),t),i),{computed:i}}(t=>(class{setPage(t){this.__page=t}get $site(){return t}get $themeConfig(){return this.$site.themeConfig}get $frontmatter(){return this.$page.frontmatter}get $localeConfig(){const{locales:t={}}=this.$site;let e,n;for(const r in t)"/"===r?n=t[r]:0===this.$page.path.indexOf(r)&&(e=t[r]);return e||n||{}}get $siteTitle(){return this.$localeConfig.title||this.$site.title||""}get $title(){const t=this.$page,{metaTitle:e}=this.$page.frontmatter;if("string"==typeof e)return e;const n=this.$siteTitle,r=t.frontmatter.home?null:t.frontmatter.title||t.title;return n?r?r+" | "+n:n:r||"VuePress"}get $description(){const t=function(t){if(t){const e=t.filter(t=>"description"===t.name)[0];if(e)return e.content}}(this.$page.frontmatter.meta);return t||(this.$page.frontmatter.description||this.$localeConfig.description||this.$site.description||"")}get $lang(){return this.$page.frontmatter.lang||this.$localeConfig.lang||"en-US"}get $localePath(){return this.$localeConfig.path||"/"}get $themeLocaleConfig(){return(this.$site.themeConfig.locales||{})[this.$localePath]||{}}get $page(){return this.__page?this.__page:function(t,e){for(let n=0;nn||(t.hash?!Uo.$vuepress.$get("disableScrollBehavior")&&{selector:t.hash}:{x:0,y:0})});!function(t){t.beforeEach((e,n,r)=>{if(ss(t,e.path))r();else if(/(\/|\.html)$/.test(e.path))if(/\/$/.test(e.path)){const n=e.path.replace(/\/$/,"")+".html";ss(t,n)?r(n):r()}else r();else{const n=e.path+"/",o=e.path+".html";ss(t,o)?r(o):ss(t,n)?r(n):r()}})}(n);const r={};try{ns.forEach(e=>{"function"==typeof e&&e({Vue:Uo,options:r,router:n,siteData:es,isServer:t})})}catch(t){console.error(t)}return{app:new Uo(Object.assign(r,{router:n,render:t=>t("div",{attrs:{id:"app"}},[t("router-view",{ref:"layout"}),t("div",{class:"global-ui"},rs.map(e=>t(e)))])})),router:n}}(!1);window.__VUEPRESS__={version:"1.2.0",hash:"1761be0"},ds.onReady(()=>{ps.$mount("#app")})}]); \ No newline at end of file + */function Fo(t){return Object.prototype.toString.call(t).indexOf("Error")>-1}function Bo(t,e){return e instanceof t||e&&(e.name===t.name||e._name===t._name)}function Vo(t,e){for(var n in e)t[n]=e[n];return t}var qo={name:"RouterView",functional:!0,props:{name:{type:String,default:"default"}},render:function(t,e){var n=e.props,r=e.children,o=e.parent,i=e.data;i.routerView=!0;for(var a=o.$createElement,s=n.name,c=o.$route,u=o._routerViewCache||(o._routerViewCache={}),l=0,f=!1;o&&o._routerRoot!==o;){var p=o.$vnode&&o.$vnode.data;p&&(p.routerView&&l++,p.keepAlive&&o._inactive&&(f=!0)),o=o.$parent}if(i.routerViewDepth=l,f)return a(u[s],i,r);var d=c.matched[l];if(!d)return u[s]=null,a();var h=u[s]=d.components[s];i.registerRouteInstance=function(t,e){var n=d.instances[s];(e&&n!==t||!e&&n===t)&&(d.instances[s]=e)},(i.hook||(i.hook={})).prepatch=function(t,e){d.instances[s]=e.componentInstance},i.hook.init=function(t){t.data.keepAlive&&t.componentInstance&&t.componentInstance!==d.instances[s]&&(d.instances[s]=t.componentInstance)};var v=i.props=function(t,e){switch(typeof e){case"undefined":return;case"object":return e;case"function":return e(t);case"boolean":return e?t.params:void 0;default:0}}(c,d.props&&d.props[s]);if(v){v=i.props=Vo({},v);var m=i.attrs=i.attrs||{};for(var y in v)h.props&&y in h.props||(m[y]=v[y],delete v[y])}return a(h,i,r)}};var Ho=/[!'()*]/g,zo=function(t){return"%"+t.charCodeAt(0).toString(16)},Wo=/%2C/g,Ko=function(t){return encodeURIComponent(t).replace(Ho,zo).replace(Wo,",")},Xo=decodeURIComponent;function Go(t){var e={};return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach((function(t){var n=t.replace(/\+/g," ").split("="),r=Xo(n.shift()),o=n.length>0?Xo(n.join("=")):null;void 0===e[r]?e[r]=o:Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]})),e):e}function Jo(t){var e=t?Object.keys(t).map((function(e){var n=t[e];if(void 0===n)return"";if(null===n)return Ko(e);if(Array.isArray(n)){var r=[];return n.forEach((function(t){void 0!==t&&(null===t?r.push(Ko(e)):r.push(Ko(e)+"="+Ko(t)))})),r.join("&")}return Ko(e)+"="+Ko(n)})).filter((function(t){return t.length>0})).join("&"):null;return e?"?"+e:""}var Qo=/\/?$/;function Yo(t,e,n,r){var o=r&&r.options.stringifyQuery,i=e.query||{};try{i=Zo(i)}catch(t){}var a={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:i,params:e.params||{},fullPath:ni(e,o),matched:t?ei(t):[]};return n&&(a.redirectedFrom=ni(n,o)),Object.freeze(a)}function Zo(t){if(Array.isArray(t))return t.map(Zo);if(t&&"object"==typeof t){var e={};for(var n in t)e[n]=Zo(t[n]);return e}return t}var ti=Yo(null,{path:"/"});function ei(t){for(var e=[];t;)e.unshift(t),t=t.parent;return e}function ni(t,e){var n=t.path,r=t.query;void 0===r&&(r={});var o=t.hash;return void 0===o&&(o=""),(n||"/")+(e||Jo)(r)+o}function ri(t,e){return e===ti?t===e:!!e&&(t.path&&e.path?t.path.replace(Qo,"")===e.path.replace(Qo,"")&&t.hash===e.hash&&oi(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&oi(t.query,e.query)&&oi(t.params,e.params)))}function oi(t,e){if(void 0===t&&(t={}),void 0===e&&(e={}),!t||!e)return t===e;var n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every((function(n){var r=t[n],o=e[n];return"object"==typeof r&&"object"==typeof o?oi(r,o):String(r)===String(o)}))}function ii(t,e,n){var r=t.charAt(0);if("/"===r)return t;if("?"===r||"#"===r)return e+t;var o=e.split("/");n&&o[o.length-1]||o.pop();for(var i=t.replace(/^\//,"").split("/"),a=0;a=0&&(e=t.slice(r),t=t.slice(0,r));var o=t.indexOf("?");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{path:t,query:n,hash:e}}(o.path||""),c=e&&e.path||"/",u=s.path?ii(s.path,c,n||o.append):c,l=function(t,e,n){void 0===e&&(e={});var r,o=n||Go;try{r=o(t||"")}catch(t){r={}}for(var i in e)r[i]=e[i];return r}(s.query,o.query,r&&r.options.parseQuery),f=o.hash||s.hash;return f&&"#"!==f.charAt(0)&&(f="#"+f),{_normalized:!0,path:u,query:l,hash:f}}var Ai,Oi=[String,Object],Si=[String,Array],Ei=function(){},ji={name:"RouterLink",props:{to:{type:Oi,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String,exactActiveClass:String,event:{type:Si,default:"click"}},render:function(t){var e=this,n=this.$router,r=this.$route,o=n.resolve(this.to,r,this.append),i=o.location,a=o.route,s=o.href,c={},u=n.options.linkActiveClass,l=n.options.linkExactActiveClass,f=null==u?"router-link-active":u,p=null==l?"router-link-exact-active":l,d=null==this.activeClass?f:this.activeClass,h=null==this.exactActiveClass?p:this.exactActiveClass,v=a.redirectedFrom?Yo(null,ki(a.redirectedFrom),null,n):a;c[h]=ri(r,v),c[d]=this.exact?c[h]:function(t,e){return 0===t.path.replace(Qo,"/").indexOf(e.path.replace(Qo,"/"))&&(!e.hash||t.hash===e.hash)&&function(t,e){for(var n in e)if(!(n in t))return!1;return!0}(t.query,e.query)}(r,v);var m=function(t){Ti(t)&&(e.replace?n.replace(i,Ei):n.push(i,Ei))},y={click:Ti};Array.isArray(this.event)?this.event.forEach((function(t){y[t]=m})):y[this.event]=m;var g={class:c},b=!this.$scopedSlots.$hasNormal&&this.$scopedSlots.default&&this.$scopedSlots.default({href:s,route:a,navigate:m,isActive:c[d],isExactActive:c[h]});if(b){if(1===b.length)return b[0];if(b.length>1||!b.length)return 0===b.length?t():t("span",{},b)}if("a"===this.tag)g.on=y,g.attrs={href:s};else{var _=function t(e){if(e)for(var n,r=0;r-1&&(s.params[p]=n.params[p]);return s.path=xi(l.path,s.params),c(l,s,a)}if(s.path){s.params={};for(var d=0;d=t.length?n():t[o]?e(t[o],(function(){r(o+1)})):r(o+1)};r(0)}function na(t){return function(e,n,r){var o=!1,i=0,a=null;ra(t,(function(t,e,n,s){if("function"==typeof t&&void 0===t.cid){o=!0,i++;var c,u=aa((function(e){var o;((o=e).__esModule||ia&&"Module"===o[Symbol.toStringTag])&&(e=e.default),t.resolved="function"==typeof e?e:Ai.extend(e),n.components[s]=e,--i<=0&&r()})),l=aa((function(t){var e="Failed to resolve async component "+s+": "+t;a||(a=Fo(t)?t:new Error(e),r(a))}));try{c=t(u,l)}catch(t){l(t)}if(c)if("function"==typeof c.then)c.then(u,l);else{var f=c.component;f&&"function"==typeof f.then&&f.then(u,l)}}})),o||r()}}function ra(t,e){return oa(t.map((function(t){return Object.keys(t.components).map((function(n){return e(t.components[n],t.instances[n],t,n)}))})))}function oa(t){return Array.prototype.concat.apply([],t)}var ia="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function aa(t){var e=!1;return function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];if(!e)return e=!0,t.apply(this,n)}}var sa=function(t){function e(e){t.call(this),this.name=this._name="NavigationDuplicated",this.message='Navigating to current location ("'+e.fullPath+'") is not allowed',Object.defineProperty(this,"stack",{value:(new t).stack,writable:!0,configurable:!0})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Error);sa._name="NavigationDuplicated";var ca=function(t,e){this.router=t,this.base=function(t){if(!t)if(Pi){var e=document.querySelector("base");t=(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else t="/";"/"!==t.charAt(0)&&(t="/"+t);return t.replace(/\/$/,"")}(e),this.current=ti,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};function ua(t,e,n,r){var o=ra(t,(function(t,r,o,i){var a=function(t,e){"function"!=typeof t&&(t=Ai.extend(t));return t.options[e]}(t,e);if(a)return Array.isArray(a)?a.map((function(t){return n(t,r,o,i)})):n(a,r,o,i)}));return oa(r?o.reverse():o)}function la(t,e){if(e)return function(){return t.apply(e,arguments)}}ca.prototype.listen=function(t){this.cb=t},ca.prototype.onReady=function(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))},ca.prototype.onError=function(t){this.errorCbs.push(t)},ca.prototype.transitionTo=function(t,e,n){var r=this,o=this.router.match(t,this.current);this.confirmTransition(o,(function(){r.updateRoute(o),e&&e(o),r.ensureURL(),r.ready||(r.ready=!0,r.readyCbs.forEach((function(t){t(o)})))}),(function(t){n&&n(t),t&&!r.ready&&(r.ready=!0,r.readyErrorCbs.forEach((function(e){e(t)})))}))},ca.prototype.confirmTransition=function(t,e,n){var r=this,o=this.current,i=function(t){!Bo(sa,t)&&Fo(t)&&(r.errorCbs.length?r.errorCbs.forEach((function(e){e(t)})):console.error(t)),n&&n(t)};if(ri(t,o)&&t.matched.length===o.matched.length)return this.ensureURL(),i(new sa(t));var a=function(t,e){var n,r=Math.max(t.length,e.length);for(n=0;n-1?decodeURI(t.slice(0,r))+t.slice(r):decodeURI(t)}else n>-1&&(t=decodeURI(t.slice(0,n))+t.slice(n));return t}function ma(t){var e=window.location.href,n=e.indexOf("#");return(n>=0?e.slice(0,n):e)+"#"+t}function ya(t){Yi?Zi(ma(t)):window.location.hash=t}function ga(t){Yi?ta(ma(t)):window.location.replace(ma(t))}var ba=function(t){function e(e,n){t.call(this,e,n),this.stack=[],this.index=-1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.push=function(t,e,n){var r=this;this.transitionTo(t,(function(t){r.stack=r.stack.slice(0,r.index+1).concat(t),r.index++,e&&e(t)}),n)},e.prototype.replace=function(t,e,n){var r=this;this.transitionTo(t,(function(t){r.stack=r.stack.slice(0,r.index).concat(t),e&&e(t)}),n)},e.prototype.go=function(t){var e=this,n=this.index+t;if(!(n<0||n>=this.stack.length)){var r=this.stack[n];this.confirmTransition(r,(function(){e.index=n,e.updateRoute(r)}),(function(t){Bo(sa,t)&&(e.index=n)}))}},e.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},e.prototype.ensureURL=function(){},e}(ca),_a=function(t){void 0===t&&(t={}),this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=Ii(t.routes||[],this);var e=t.mode||"hash";switch(this.fallback="history"===e&&!Yi&&!1!==t.fallback,this.fallback&&(e="hash"),Pi||(e="abstract"),this.mode=e,e){case"history":this.history=new fa(this,t.base);break;case"hash":this.history=new da(this,t.base,this.fallback);break;case"abstract":this.history=new ba(this,t.base);break;default:0}},wa={currentRoute:{configurable:!0}};function $a(t,e){return t.push(e),function(){var n=t.indexOf(e);n>-1&&t.splice(n,1)}}_a.prototype.match=function(t,e,n){return this.matcher.match(t,e,n)},wa.currentRoute.get=function(){return this.history&&this.history.current},_a.prototype.init=function(t){var e=this;if(this.apps.push(t),t.$once("hook:destroyed",(function(){var n=e.apps.indexOf(t);n>-1&&e.apps.splice(n,1),e.app===t&&(e.app=e.apps[0]||null)})),!this.app){this.app=t;var n=this.history;if(n instanceof fa)n.transitionTo(n.getCurrentLocation());else if(n instanceof da){var r=function(){n.setupListeners()};n.transitionTo(n.getCurrentLocation(),r,r)}n.listen((function(t){e.apps.forEach((function(e){e._route=t}))}))}},_a.prototype.beforeEach=function(t){return $a(this.beforeHooks,t)},_a.prototype.beforeResolve=function(t){return $a(this.resolveHooks,t)},_a.prototype.afterEach=function(t){return $a(this.afterHooks,t)},_a.prototype.onReady=function(t,e){this.history.onReady(t,e)},_a.prototype.onError=function(t){this.history.onError(t)},_a.prototype.push=function(t,e,n){var r=this;if(!e&&!n&&"undefined"!=typeof Promise)return new Promise((function(e,n){r.history.push(t,e,n)}));this.history.push(t,e,n)},_a.prototype.replace=function(t,e,n){var r=this;if(!e&&!n&&"undefined"!=typeof Promise)return new Promise((function(e,n){r.history.replace(t,e,n)}));this.history.replace(t,e,n)},_a.prototype.go=function(t){this.history.go(t)},_a.prototype.back=function(){this.go(-1)},_a.prototype.forward=function(){this.go(1)},_a.prototype.getMatchedComponents=function(t){var e=t?t.matched?t:this.resolve(t).route:this.currentRoute;return e?[].concat.apply([],e.matched.map((function(t){return Object.keys(t.components).map((function(e){return t.components[e]}))}))):[]},_a.prototype.resolve=function(t,e,n){var r=ki(t,e=e||this.history.current,n,this),o=this.match(r,e),i=o.redirectedFrom||o.fullPath;return{location:r,route:o,href:function(t,e,n){var r="hash"===n?"#"+e:e;return t?ai(t+"/"+r):r}(this.history.base,i,this.mode),normalizedTo:r,resolved:o}},_a.prototype.addRoutes=function(t){this.matcher.addRoutes(t),this.history.current!==ti&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(_a.prototype,wa),_a.install=function t(e){if(!t.installed||Ai!==e){t.installed=!0,Ai=e;var n=function(t){return void 0!==t},r=function(t,e){var r=t.$options._parentVnode;n(r)&&n(r=r.data)&&n(r=r.registerRouteInstance)&&r(t,e)};e.mixin({beforeCreate:function(){n(this.$options.router)?(this._routerRoot=this,this._router=this.$options.router,this._router.init(this),e.util.defineReactive(this,"_route",this._router.history.current)):this._routerRoot=this.$parent&&this.$parent._routerRoot||this,r(this,this)},destroyed:function(){r(this)}}),Object.defineProperty(e.prototype,"$router",{get:function(){return this._routerRoot._router}}),Object.defineProperty(e.prototype,"$route",{get:function(){return this._routerRoot._route}}),e.component("RouterView",qo),e.component("RouterLink",ji);var o=e.config.optionMergeStrategies;o.beforeRouteEnter=o.beforeRouteLeave=o.beforeRouteUpdate=o.created}},_a.version="3.1.3",Pi&&window.Vue&&window.Vue.use(_a);var Ca=_a;var xa={NotFound:()=>n.e(4).then(n.bind(null,204)),Layout:()=>Promise.all([n.e(0),n.e(2)]).then(n.bind(null,203))},ka={"v-3c88bbf2":()=>n.e(5).then(n.bind(null,205)),"v-0decf914":()=>n.e(6).then(n.bind(null,206)),"v-d7e5bcfc":()=>n.e(7).then(n.bind(null,207)),"v-6d148503":()=>n.e(9).then(n.bind(null,208)),"v-4419f5c9":()=>n.e(8).then(n.bind(null,209)),"v-70457f72":()=>n.e(10).then(n.bind(null,210)),"v-7bafdcee":()=>n.e(11).then(n.bind(null,211)),"v-300a59ee":()=>n.e(12).then(n.bind(null,212))};function Aa(t){const e=Object.create(null);return function(n){return e[n]||(e[n]=t(n))}}const Oa=/-(\w)/g,Sa=Aa(t=>t.replace(Oa,(t,e)=>e?e.toUpperCase():"")),Ea=/\B([A-Z])/g,ja=Aa(t=>t.replace(Ea,"-$1").toLowerCase()),Ta=Aa(t=>t.charAt(0).toUpperCase()+t.slice(1));function Pa(t,e){if(!e)return;if(t(e))return t(e);return e.includes("-")?t(Ta(Sa(e))):t(Ta(e))||t(ja(e))}const Ra=Object.assign({},xa,ka),La=t=>Ra[t],Ia=t=>ka[t],Ma=t=>xa[t],Da=t=>Uo.component(t);function Na(t){return Pa(Ia,t)}function Ua(t){return Pa(Ma,t)}function Fa(t){return Pa(La,t)}function Ba(t){return Pa(Da,t)}function Va(...t){return Promise.all(t.filter(t=>t).map(async t=>{if(!Ba(t)&&Fa(t)){const e=await Fa(t)();Uo.component(t,e.default)}}))}function qa(t,e){"undefined"!=typeof window&&window.__VUEPRESS__&&(window.__VUEPRESS__[t]=e)}var Ha={created(){this.$ssrContext&&(this.$ssrContext.title=this.$title,this.$ssrContext.lang=this.$lang,this.$ssrContext.description=this.$page.description||this.$description)},mounted(){this.currentMetaTags=new Set,this.updateMeta()},methods:{updateMeta(){document.title=this.$title,document.documentElement.lang=this.$lang;const t=this.$page.frontmatter.meta||[],e=t.slice(0);0===t.filter(t=>"description"===t.name).length&&e.push({name:"description",content:this.$description});const n=document.querySelectorAll('meta[name="description"]');n.length&&n.forEach(t=>this.currentMetaTags.add(t)),this.currentMetaTags=new Set(za(e,this.currentMetaTags))}},watch:{$page(){this.updateMeta()}},beforeDestroy(){za(null,this.currentMetaTags)}};function za(t,e){if(e&&[...e].forEach(t=>{document.head.removeChild(t)}),t)return t.map(t=>{const e=document.createElement("meta");return Object.keys(t).forEach(n=>{e.setAttribute(n,t[n])}),document.head.appendChild(e),e})}var Wa=n(3),Ka={mounted(){window.addEventListener("scroll",this.onScroll)},methods:{onScroll:n.n(Wa)()((function(){this.setActiveHash()}),300),setActiveHash(){const t=[].slice.call(document.querySelectorAll(".sidebar-link")),e=[].slice.call(document.querySelectorAll(".header-anchor")).filter(e=>t.some(t=>t.hash===e.hash)),n=Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop),r=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),o=window.innerHeight+n;for(let t=0;t=i.parentElement.offsetTop+10&&(!a||n{this.$nextTick(()=>{this.$vuepress.$set("disableScrollBehavior",!1)})})}}}},beforeDestroy(){window.removeEventListener("scroll",this.onScroll)}},Xa=n(2),Ga=n.n(Xa),Ja=[Ha,Ka,{mounted(){Ga.a.configure({showSpinner:!1}),this.$router.beforeEach((t,e,n)=>{t.path===e.path||Uo.component(t.name)||Ga.a.start(),n()}),this.$router.afterEach(()=>{Ga.a.done(),this.isSidebarOpen=!1})}}],Qa={methods:{getLayout:function(){if(this.$page.path){var t=this.$page.frontmatter.layout;return t&&(this.$vuepress.getLayoutAsyncComponent(t)||this.$vuepress.getVueComponent(t))?t:"Layout"}return"NotFound"}},computed:{layout:function(){var t=this.getLayout();return qa("layout",t),Uo.component(t)}}},Ya=n(0),Za=Object(Ya.a)(Qa,(function(){var t=this.$createElement;return(this._self._c||t)(this.layout,{tag:"component"})}),[],!1,null,null,null).exports;!function(t,e,n){switch(e){case"components":t[e]||(t[e]={}),Object.assign(t[e],n);break;case"mixins":t[e]||(t[e]=[]),t[e].push(...n);break;default:throw new Error("Unknown option name.")}}(Za,"mixins",Ja);const ts=[{name:"v-3c88bbf2",path:"/",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-3c88bbf2").then(n)}},{path:"/index.html",redirect:"/"},{name:"v-0decf914",path:"/about/",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-0decf914").then(n)}},{path:"/about/index.html",redirect:"/about/"},{name:"v-d7e5bcfc",path:"/docs/",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-d7e5bcfc").then(n)}},{path:"/docs/index.html",redirect:"/docs/"},{name:"v-6d148503",path:"/docs/interop.html",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-6d148503").then(n)}},{name:"v-4419f5c9",path:"/docs/examples.html",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-4419f5c9").then(n)}},{name:"v-70457f72",path:"/docs/introspection.html",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-70457f72").then(n)}},{name:"v-7bafdcee",path:"/docs/schema.html",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-7bafdcee").then(n)}},{name:"v-300a59ee",path:"/docs/validation.html",component:Za,beforeEnter:(t,e,n)=>{Va("Layout","v-300a59ee").then(n)}},{path:"*",component:Za}],es={title:"",description:"",base:"/caliban/",pages:[{title:"Home",frontmatter:{home:!0,heroImage:"/caliban.svg",actionText:"Get Started →",actionLink:"/docs/",features:[{title:"Purely functional",details:"All interfaces are pure and types are referentially transparent."},{title:"Minimal boilerplate",details:"No need to manually define a schema for every type in your API."},{title:"Type safe schema",details:"Schema is derived at compile-time. Resolver is provided at runtime."}]},regularPath:"/",relativePath:"README.md",key:"v-3c88bbf2",path:"/"},{title:"About",frontmatter:{},regularPath:"/about/",relativePath:"about/README.md",key:"v-0decf914",path:"/about/"},{title:"Getting Started",frontmatter:{},regularPath:"/docs/",relativePath:"docs/README.md",key:"v-d7e5bcfc",path:"/docs/",headers:[{level:2,title:"Dependencies",slug:"dependencies"},{level:2,title:"A simple example",slug:"a-simple-example"},{level:2,title:"Mutations",slug:"mutations"},{level:2,title:"Subscriptions",slug:"subscriptions"}]},{title:"Interop (Cats)",frontmatter:{},regularPath:"/docs/interop.html",relativePath:"docs/interop.md",key:"v-6d148503",path:"/docs/interop.html"},{title:"Examples",frontmatter:{},regularPath:"/docs/examples.html",relativePath:"docs/examples.md",key:"v-4419f5c9",path:"/docs/examples.html"},{title:"Introspection",frontmatter:{},regularPath:"/docs/introspection.html",relativePath:"docs/introspection.md",key:"v-70457f72",path:"/docs/introspection.html"},{title:"Schemas",frontmatter:{},regularPath:"/docs/schema.html",relativePath:"docs/schema.md",key:"v-7bafdcee",path:"/docs/schema.html",headers:[{level:2,title:"Enum and union",slug:"enum-and-union"},{level:2,title:"Arguments",slug:"arguments"},{level:2,title:"Effects",slug:"effects"},{level:2,title:"Annotations",slug:"annotations"},{level:2,title:"Custom types",slug:"custom-types"}]},{title:"Validation",frontmatter:{},regularPath:"/docs/validation.html",relativePath:"docs/validation.md",key:"v-300a59ee",path:"/docs/validation.html"}],themeConfig:{logo:"/caliban.svg",locales:{"/":{selectText:"Language",label:"English",nav:[{text:"Documentation",link:"/docs/"},{text:"About",link:"/about/"},{text:"Github",link:"https://github.com/ghostdogpr/caliban"},{text:"Scaladoc",link:"https://javadoc.io/doc/com.github.ghostdogpr/caliban_2.12/"}],sidebar:{"/docs/":[{title:"Caliban",collapsable:!1,sidebarDepth:2,children:["","schema","validation","introspection","interop","examples"]}]}}}},locales:{"/":{lang:"en-US",title:"Caliban",description:"Functional GraphQL backend in Scala",path:"/"}}};n(5);Uo.component("Badge",()=>Promise.all([n.e(0),n.e(3)]).then(n.bind(null,213)));n(6);var ns=[{},({Vue:t})=>{t.mixin({computed:{$dataBlock(){return this.$options.__data__block__}}})},{},{}],rs=[];class os{constructor(){this.store=new Uo({data:{state:{}}})}$get(t){return this.store.state[t]}$set(t,e){Uo.set(this.store.state,t,e)}$emit(...t){this.store.$emit(...t)}$on(...t){this.store.$on(...t)}}class is extends os{}Object.assign(is.prototype,{getPageAsyncComponent:Na,getLayoutAsyncComponent:Ua,getAsyncComponent:Fa,getVueComponent:Ba});var as={install(t){const e=new is;t.$vuepress=e,t.prototype.$vuepress=e}};function ss(t,e){return t.options.routes.filter(t=>t.path.toLowerCase()===e.toLowerCase()).length>0}var cs={props:{pageKey:String,slotKey:{type:String,default:"default"}},render(t){const e=this.pageKey||this.$parent.$page.key;return qa("pageKey",e),Uo.component(e)||Uo.component(e,Na(e)),Uo.component(e)?t(e):t("")}},us={functional:!0,props:{slotKey:String,required:!0},render:(t,{props:e,slots:n})=>t("div",{class:[`content__${e.slotKey}`]},n()[e.slotKey])},ls=(n(7),Object(Ya.a)({},(function(t,e){var n=e._c;return n("svg",{staticClass:"icon outbound",attrs:{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",x:"0px",y:"0px",viewBox:"0 0 100 100",width:"15",height:"15"}},[n("path",{attrs:{fill:"currentColor",d:"M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"}}),e._v(" "),n("polygon",{attrs:{fill:"currentColor",points:"45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"}})])}),[],!0,null,null,null).exports),fs={functional:!0,render(t,{parent:e,children:n}){if(e._isMounted)return n;e.$once("hook:mounted",()=>{e.$forceUpdate()})}};Uo.config.productionTip=!1,Uo.use(Ca),Uo.use(as),Uo.mixin(function(t,e,n=Uo){!function(t){t.locales&&Object.keys(t.locales).forEach(e=>{t.locales[e].path=e});Object.freeze(t)}(e),n.$vuepress.$set("siteData",e);const r=new(t(n.$vuepress.$get("siteData"))),o=Object.getOwnPropertyDescriptors(Object.getPrototypeOf(r)),i={};return Object.keys(o).reduce((t,e)=>(e.startsWith("$")&&(t[e]=o[e].get),t),i),{computed:i}}(t=>(class{setPage(t){this.__page=t}get $site(){return t}get $themeConfig(){return this.$site.themeConfig}get $frontmatter(){return this.$page.frontmatter}get $localeConfig(){const{locales:t={}}=this.$site;let e,n;for(const r in t)"/"===r?n=t[r]:0===this.$page.path.indexOf(r)&&(e=t[r]);return e||n||{}}get $siteTitle(){return this.$localeConfig.title||this.$site.title||""}get $title(){const t=this.$page,{metaTitle:e}=this.$page.frontmatter;if("string"==typeof e)return e;const n=this.$siteTitle,r=t.frontmatter.home?null:t.frontmatter.title||t.title;return n?r?r+" | "+n:n:r||"VuePress"}get $description(){const t=function(t){if(t){const e=t.filter(t=>"description"===t.name)[0];if(e)return e.content}}(this.$page.frontmatter.meta);return t||(this.$page.frontmatter.description||this.$localeConfig.description||this.$site.description||"")}get $lang(){return this.$page.frontmatter.lang||this.$localeConfig.lang||"en-US"}get $localePath(){return this.$localeConfig.path||"/"}get $themeLocaleConfig(){return(this.$site.themeConfig.locales||{})[this.$localePath]||{}}get $page(){return this.__page?this.__page:function(t,e){for(let n=0;nn||(t.hash?!Uo.$vuepress.$get("disableScrollBehavior")&&{selector:t.hash}:{x:0,y:0})});!function(t){t.beforeEach((e,n,r)=>{if(ss(t,e.path))r();else if(/(\/|\.html)$/.test(e.path))if(/\/$/.test(e.path)){const n=e.path.replace(/\/$/,"")+".html";ss(t,n)?r(n):r()}else r();else{const n=e.path+"/",o=e.path+".html";ss(t,o)?r(o):ss(t,n)?r(n):r()}})}(n);const r={};try{ns.forEach(e=>{"function"==typeof e&&e({Vue:Uo,options:r,router:n,siteData:es,isServer:t})})}catch(t){console.error(t)}return{app:new Uo(Object.assign(r,{router:n,render:t=>t("div",{attrs:{id:"app"}},[t("router-view",{ref:"layout"}),t("div",{class:"global-ui"},rs.map(e=>t(e)))])})),router:n}}(!1);window.__VUEPRESS__={version:"1.2.0",hash:"71c1062"},ds.onReady(()=>{ps.$mount("#app")})}]); \ No newline at end of file diff --git a/docs/docs/examples.html b/docs/docs/examples.html index 5a7822c75..9c45cb862 100644 --- a/docs/docs/examples.html +++ b/docs/docs/examples.html @@ -7,7 +7,7 @@ - + @@ -19,9 +19,9 @@ Github

# Examples

A sample project showing how to serve a simple GraphQL schema over HTTP and WebSocket using http4s is available in the examples folder.

# Examples

A sample project showing how to serve a simple GraphQL schema over HTTP and WebSocket using http4s is available in the examples folder.

- +

+ diff --git a/docs/docs/index.html b/docs/docs/index.html index 359fc66d1..8ff1b3f47 100644 --- a/docs/docs/index.html +++ b/docs/docs/index.html @@ -7,7 +7,7 @@ - + @@ -19,8 +19,10 @@ Github

# Getting Started

Caliban is a purely functional library for creating GraphQL backends in Scala. +

# Getting Started

Caliban is a purely functional library for creating GraphQL backends in Scala. It relies on Magnolia to automatically derives GraphQL schemas from your data types, Fastparse to parse queries and ZIO to handle various effects.

The design principles behind the library are the following:

  • pure interface: errors and effects are returned explicitly (no exceptions thrown), all returned types are referentially transparent (no Future).
  • clean separation between schema definition and implementation: schema is defined and validated at compile-time (no reflection) using Scala standard types, resolver is a simple value provided at runtime.
  • minimal amount of boilerplate: no need to manually define a schema for every type in your API.

# Dependencies

To use caliban, add the following line in your build.sbt file:

libraryDependencies += "com.github.ghostdogpr" %% "caliban" % "0.1.0"
+

The following modules are optional:

libraryDependencies += "com.github.ghostdogpr" %% "caliban-http4s" % "0.1.0" // routes for http4s
+libraryDependencies += "com.github.ghostdogpr" %% "caliban-cats"   % "TODO"  // interop with cats effect
 

Note that Caliban is also available for ScalaJS.

# A simple example

Creating a GraphQL API with Caliban is as simple as creating a case class. Indeed, the whole GraphQL schema will be derived from a case class structure (its fields and the other types it references), and the resolver is just an instance of that case class.

Let's say we have a class Character and 2 functions: getCharacters and getCharacter:

case class Character(name: String)
 
 def getCharacters: List[Character] = ???
@@ -63,6 +65,6 @@
 

All the fields of the subscription root case class MUST return ZStream objects. When a subscription request is received, an output stream of ResponseValue will be returned wrapped in an ObjectValue.

- + diff --git a/docs/docs/interop.html b/docs/docs/interop.html new file mode 100644 index 000000000..b66422e12 --- /dev/null +++ b/docs/docs/interop.html @@ -0,0 +1,56 @@ + + + + + + Interop (Cats) | Caliban + + + + + + + +

# Interop (Cats)

If you prefer using Monix or Cats IO rather than ZIO, you can use the caliban-cats module.

You first need to import caliban.interop.cats.implicits._ and have an implicit zio.Runtime in scope. Then a few helpers are available:

  • the GraphQL object is enriched with executeAsync and checkAsync, variants of execute and check that return an F[_]: Async instead of a ZIO.
  • the Http4sAdapter also has cats-effect variants named makeRestServiceF and makeWebSocketServiceF.

In addition to that, a Schema for any F[_]: Effect is provided. That means you can include fields returning Monix Task for Cats IO in your queries, mutations or subscriptions.

The following example shows how to create an interpreter and run a query while only using Cats IO.

import caliban.GraphQL.graphQL
+import caliban.RootResolver
+import caliban.interop.cats.implicits._
+import cats.effect.{ ExitCode, IO, IOApp }
+import zio.DefaultRuntime
+
+object ExampleCatsInterop extends IOApp {
+
+  implicit val runtime = new DefaultRuntime {}
+
+  case class Queries(numbers: List[Int], randomNumber: IO[Int])
+
+  val queries     = Queries(List(1, 2, 3, 4), IO(scala.util.Random.nextInt()))
+  val interpreter = graphQL(RootResolver(queries))
+
+  val query = """
+  {
+    numbers
+    randomNumber
+  }"""
+
+  override def run(args: List[String]): IO[ExitCode] =
+    for {
+      result <- interpreter.executeAsync[IO](query)
+      _      <- IO(println(result))
+    } yield ExitCode.Success
+}
+

You can find this example within the examples project.

+ + + diff --git a/docs/docs/introspection.html b/docs/docs/introspection.html index 9dc5262af..afa7a768e 100644 --- a/docs/docs/introspection.html +++ b/docs/docs/introspection.html @@ -7,7 +7,7 @@ - + @@ -19,11 +19,11 @@ Github

# Introspection

Introspection queries are fully supported, which means you can use your favorite tool to inspect your schema and generate documentation for free.

Here's an example of documentation generated by introspection in Altair GraphQL Client:

altair screenshot

# Introspection

Introspection queries are fully supported, which means you can use your favorite tool to inspect your schema and generate documentation for free.

Here's an example of documentation generated by introspection in Altair GraphQL Client:

altair screenshot

- + diff --git a/docs/docs/schema.html b/docs/docs/schema.html index b1f8c84c6..be0557762 100644 --- a/docs/docs/schema.html +++ b/docs/docs/schema.html @@ -7,7 +7,7 @@ - + @@ -19,7 +19,7 @@ Github

# Schemas

A GraphQL schema will be derived automatically at compile-time (no reflection) from the types present in your resolver. +

# Schemas

A GraphQL schema will be derived automatically at compile-time (no reflection) from the types present in your resolver. The table below shows how common Scala types are converted to GraphQL types.

Scala Type GraphQL Type
Boolean Boolean
Int Int
Float Float
String String
Unit Unit (custom scalar)
Long Long (custom scalar)
Double Double (custom scalar)
Case Class Object
Sealed Trait Enum or Union
Option[A] Nullable A
List[A] List of A
Set[A] List of A
A => B A and B
(A, B) Object with 2 fields _1 and _2
Either[A, B] Object with 2 nullable fields left and right
Map[A, B] List of Object with 2 fields key and value
ZIO[R, E, A] A
ZStream[R, E, A] A

See the Custom Types section to find out how to support your own types.

If you want Caliban to support other standard types, feel free to file an issue or even a PR.

WARNING

Magnolia (the library used to derive the schema at compile-time) sometimes has some trouble generating schemas with a lot of nested types, or types reused in multiple places. to deal with this, you can declare schemas for your case classes and sealed traits explicitly:

implicit val roleSchema      = Schema.gen[Role]
 implicit val characterSchema = Schema.gen[Character]
@@ -70,6 +70,6 @@
        Validation

- + diff --git a/docs/docs/validation.html b/docs/docs/validation.html index a8ba9e948..37b7afb8b 100644 --- a/docs/docs/validation.html +++ b/docs/docs/validation.html @@ -7,7 +7,7 @@ - + @@ -19,7 +19,7 @@ Github

# Validation

Caliban provides a little macro called gqldoc that can check at compile-time that a GraphQL query (a document to be exact) has valid syntax.

import caliban.Macros.gqldoc
+  

# Validation

Caliban provides a little macro called gqldoc that can check at compile-time that a GraphQL query (a document to be exact) has valid syntax.

import caliban.Macros.gqldoc
 
 val query = gqldoc("""
   query test {
@@ -33,6 +33,6 @@
        Introspection

- + diff --git a/docs/index.html b/docs/index.html index fe5a39bef..ff9a0ec49 100644 --- a/docs/index.html +++ b/docs/index.html @@ -7,7 +7,7 @@ - + @@ -22,6 +22,6 @@
hero

Caliban

Functional GraphQL backend in Scala

Get Started →

Purely functional

All interfaces are pure and types are referentially transparent.

Minimal boilerplate

No need to manually define a schema for every type in your API.

Type safe schema

Schema is derived at compile-time. Resolver is provided at runtime.

- +