This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sangria.schema._ | |
import sangria.execution._ | |
import sangria.macros._ | |
import sangria.macros.derive._ | |
import sangria.marshalling.circe._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import io.circe.generic.auto._ | |
// Some basic data structures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Imports that you are using | |
import sangria.schema._ | |
import sangria.execution._ | |
import sangria.macros._ | |
import sangria.marshalling.circe._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
// The schema definition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed abstract class DiscountCodeUpdateAction | |
case class SetDiscountCodeName(name: Option[LocalizedString]) | |
extends DiscountCodeUpdateAction | |
case class SetDiscountCodeDescription(description: Option[LocalizedString]) | |
extends DiscountCodeUpdateAction | |
case class SetDiscountCodeCartPredicate(cartPredicate: Option[String]) | |
extends DiscountCodeUpdateAction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutation UpdateDC { | |
updateDiscountCode( | |
id: "123" | |
version: 5 | |
actions: [ | |
{setName: {name: {locale: "en", value: "10% off"}}} | |
{changeIsActive: {isActive: false}} | |
] | |
) { | |
id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input DiscountCodeUpdateAction { | |
setName: SetDiscountCodeName | |
setDescription: SetDiscountCodeDescription | |
setCartPredicate: SetDiscountCodeCartPredicate | |
setCustomType: SetDiscountCodeCustomType | |
setCustomField: SetDiscountCodeCustomField | |
# ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extend type Mutation { | |
createDiscountCode(draft: DiscountCodeDraft!): DiscountCode | |
updateDiscountCode( | |
id: String!, | |
version: Long!, | |
actions: [DiscountCodeUpdateAction!]!): DiscountCode | |
deleteDiscountCode(id: String!, version: Long!): DiscountCode | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sangria.marshalling.MarshallingUtil._ | |
import sangria.marshalling.circe._ | |
val marchaller: ResultMarshaller = ??? // provided in ExceptionHandler | |
val json: Json = ??? // your custom json | |
implicit val mForType = SimpleResultMarshallerForType[marchaller.Node](marchaller) | |
val converted: marchaller.Node = json.convertMarshaled[marchaller.Node] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function (global) { | |
/** | |
* This GraphiQL example illustrates how to use some of GraphiQL's props | |
* in order to enable reading and updating the URL parameters, making | |
* link sharing of queries a little bit easier. | |
* | |
* This is only one example of this kind of feature, GraphiQL exposes | |
* various React params to enable interesting integrations. | |
*/ | |
var graphiql = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For build.sbt: | |
// | |
// libraryDependencies ++= Seq( | |
// "io.circe" %% "circe-core" % "0.9.2", | |
// "io.circe" %% "circe-parser" % "0.9.2", | |
// "com.jayway.jsonpath" % "json-path" % "2.3.0") | |
import com.jayway.jsonpath.{InvalidJsonException, JsonPathException, Configuration, JsonPath, TypeRef} | |
import com.jayway.jsonpath.spi.json.JsonProvider | |
import com.jayway.jsonpath.spi.mapper.MappingProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sangria.ast | |
import sangria.ast.AstVisitor | |
import sangria.schema._ | |
import sangria.renderer.{QueryRenderer, QueryRendererConfig, SchemaFilter} | |
import sangria.visitor.VisitorCommand | |
def renderSchemaWithLegacyDescriptions(schema: Schema[_, _], filter: SchemaFilter = SchemaFilter.withoutSangriaBuiltIn, config: QueryRendererConfig = QueryRenderer.Pretty) = { | |
def commentDescription(node: ast.WithDescription) = | |
node.description.toVector.flatMap(sv ⇒ sv.value.split("\\r?\\n").toVector.map(ast.Comment(_))) |
NewerOlder