Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Roni Yosofov
@ronifintech_gitlab
Hey guys,
anybody has an example on how to get all of these to work together?
GraphQL
Scala
AWS
Serverless
I've used GraphQL but only with Node... trying to use it with Scala right now and get it running as serverless
Sebastian Bruckner
@Sebruck

Hi,

I have want to, based on the selected fields of a related object, return the data either from ctx.value or from a Fetcher if I need more data. What is the best way to approach this? Projections? Custom DeferredResolver?

I found some hints but no documentation/examples to get it working.

Any help is appreciated!! Thanks a lot!

Andrey Tararaksin
@atararaksin
Hi guys! Could anyone throw a link to some reference project that uses Sangria with circe?
Miguel Carmona
@mkarmona
Hi everybody! I do still have problems with uniontypes as I would need not just to get the objects but resolve them before rendering them through the api
sangria.execution.UndefinedConcreteTypeError: Can't find appropriate subtype of a union type 'MSearchResultType' for value of class 'sangria.execution.deferred.FetcherDeferredOpt' at path 'msearch.topHit'. Possible types: Target (defined for 'models.entities.Target'), Drug (defined for 'models.entities.Drug'). Got value: FetcherDeferredOpt(sangria.execution.deferred.Fetcher@1b2b194b,ENSG00000204673). (line 4, column 5):
any example to look at that contains uniontypes and resolvers
thanks in advance!
Andrey Tararaksin
@atararaksin
Self-answer concerning circe-sangria example project: https://github.com/sangria-graphql/sangria-akka-http-example
Prasoon Joshi
@prasoonj
Hola! How do I model an InterfaceType for a trait that has no fields? If this feels like an XY problem please let me know, I'd be glad to provide more information.
Prasoon Joshi
@prasoonj
For now I've added an artificial field to the interface but, I feel it is a very ugly solution. Something better would be great! Thanks in advance.
Krutarth Patel
@tunnol
is there a way to have a trait definition sent as string and let application do the serializing/deserializing ? i have something similar to https://sangria-graphql.org/learn/#enumtype-derivation and am hoping to send as "RedApple" (string) instead of RedApple (Fruit type). sending as string from graphql ui throws an error of Expected value of Fruit type instead of string..
Krutarth Patel
@tunnol
or better way to frame my question: I am using SprayJson to format case classes on client side. On formatting, trait formatter would return JsString("..."). But that value is actually a type on graphql schema. What changes should I make to connect the dots between JsString("...") for trait and enum type on graphql schema..
Sebastian Bruckner
@Sebruck

Hi everyone,

first of all a huge THANK YOU for all the effort you put into continuing this project!

I just released the first version of a small library which connects Sangria with Akka HTTP, it is based on Olegs example.

I'd be very happy to get some feedback!

https://github.com/Sebruck/akka-http-graphql

Have a nice weekend!

(using circe!)
Travis Brown
@travisbrown
I've just published 9 of Sangria's 18 modules for Scala 2.13, and I think it'd make sense to publish the core module as a 2.0.0-M1 soon (today?): sangria-graphql-org/sangria#1
Any objections?
MrKustra94
@MrKustra94
Hi everyone.
I have a problem with derivation of mutations. Let's assume that I have following value class with validation:
case class Id private (id: String)

object Id {
  def apply(id: String): Either[Throwable, Id] = ???
}
And let's assume that I treat it as an alias:
implicit val IdScalarAlias: ScalarAlias[Id, String] = ScalarAlias(
    StringType,
    _.id,
    Id(_).left.map(throw _)
  )
MrKustra94
@MrKustra94
And also following code:
import sangria.macros.derive._
import io.circe.generic.auto._
import sangria.marshalling.circe._
import sangria.schema._
//
//

  trait Mutation {
    @GraphQLField
    def doSomething(request: Request): Value
  }

  case class Value(string: String) extends AnyVal

  case class Request(
    id: Id,
    value: Value
  )

  implicit val ValueType: ObjectType[Unit, Value] = deriveObjectType[Unit, Value]()

  implicit val ValueInputType: InputObjectType[Value] = deriveInputObjectType[Value]()

  implicit val RequestInputType: InputObjectType[Request] = deriveInputObjectType[Request]()

  implicit val MutationObject: ObjectType[Mutation, Unit] =
    deriveContextObjectType[Mutation, Mutation, Unit](identity)
Then I have problem with:
 Type com.sangria.Example.Request @@ sangria.marshalling.FromInput.InputObjectResult cannot be used as an input. Please consider defining an implicit instance of `FromInput` for
I don't know what to do with it.
Is that because of the Id?
MrKustra94
@MrKustra94
I've seen that adding Decoder[Id] has solved the issue, but I would rather keep the validation from ScalarAlias. Is there any other way?
Sebastian Bruckner
@Sebruck

@travisbrown

I've just published 9 of Sangria's 18 modules for Scala 2.13, and I think it'd make sense to publish the core module as a 2.0.0-M1 soon (today?): sangria-graphql-org/sangria#1

Awesome ❤️

Travis Brown
@travisbrown
Sebastian Bruckner
@Sebruck
Cool thx! Will update my new library on Monday to cross publish 2.12 and 2.13
Yann Simon
@yanns
Just released https://github.com/sangria-graphql-org/sangria-play-json/releases/tag/v2.0.0 that is also available for scala 2.13.
Yann Simon
@yanns
Travis Brown
@travisbrown
@yanns Great! I'm checking them off here: sangria-graphql/sangria#440
I've opened a PR for sangria-rxscala but RxScala itself doesn't support 2.13 yet, so we're blocked there.
I also started a PR for sangria-slowlog, but there are some significant changes in the OpenTracing API that will require code changes. I'll try to push a WIP branch later today.
Yann Simon
@yanns
Andriy Plokhotnyuk
@plokhotnyuk
ICYMI: json4s is vulnerable under DoS/DoW attacks which exploit hash collision vulnerabilities of Scala's HashMap or parsing vulnerabilities of Java's BigInteger/BigDecimal values
Yann Simon
@yanns
just released https://github.com/sangria-graphql-org/sangria-json4s-native/releases/tag/v1.0.1 that is also available for scala 2.13
Yann Simon
@yanns
Sangria slowlogs is now available for scala 2.13: https://github.com/sangria-graphql-org/sangria-slowlog/releases/tag/v2.0.0-M1
This version introduces breaking changes and is not available for scala 2.11 anymore.
Binh Nguyen
@ngbinh
:clap:
Andrey Tararaksin
@atararaksin

Hey guys, any ideas why wouldn't this work? This is just a minimal test of ScalarAlias (and custom scalars in general):

  case class Foo(s: String)
  case class FooWrapper(foo: Foo)
  implicit val FooType = ScalarAlias[Foo, String](StringType, _.s, s => Right(Foo(s)))
  val FooWrapperInputType = deriveInputObjectType[FooWrapper]()
  val FooWrapperArg = Argument("data", FooWrapperInputType)

  val Query = ObjectType(
    "Query",
    fields[GraphQLContext, Unit](
      Field("testFoo", StringType, arguments = FooWrapperArg::Nil, resolve = c => "ok")
    )
  )

Sending this query

query { testFoo(data: {foo: "test"}) }

results in

{
  "data": null,
  "errors": [
    {
      "message": "Argument 'data' has invalid value: Attempt to decode value on failed cursor: DownField(s),DownField(foo) (line 28, column 17):\n  testFoo(data: {foo: \"test\"})\n                ^",
      "path": [
        "testFoo"
      ],
      "locations": [
        {
          "line": 28,
          "column": 17
        }
      ]
    }
  ]
}
And interestingly, this happens only if I use Foo inside FooWrapper: if the argument contains Foo directly instead of FooWrapper, everything works (the query than would be query { testFoo(data: "test") })
Andrey Tararaksin
@atararaksin
Answer to myself: I need to define a FormInput[FooWrapper] in scope. The one derived automatically by circe-support has no notion of my Foo scalar, so it treats it as a normal case class. So it expects the foo field to be an object with s: String field, hence the error message.
Would be cool though if there still was some way to derive FormInput for such cases automatically.
Erik
@ErikHedblom

Hello, I'm debugging this sangria-graphql/sangria#465 where sangria fails to resolve SequenceLeafAction. I'm having a hard time understanding how the resolveActionsPar function works.

I'm especially interested in the purpose of resolveDctx. Is there any documentation regarding this or any one who might be able to help me with this?

Miguel Carmona
@mkarmona
I am trying to use my controller programatically internally in the same API so I need ot provide a Document. Is there a simple way of creatring documents from the schema query definition and pass the arguments the funcion needs? thanks in advance
Miguel Carmona
@mkarmona
well, does anyone know if there is an easy way of filling this just passing the arguments the query needs?
val docQ = Document(definitions = Vector(
      OperationDefinition(
        operationType=OperationType.Query,
        name=Some(qName),
        selections=GQLSchema.query.fieldsByName("drug")
      ))
    )
fieldsByName gives me the query I would like to execute but how to extract it and pass the proper arguments the object needs ?
Patrick Skjennum
@Habitats

I'm using sangria with circe, and bundling the serialization boilerplate in the companion object like so:

case class Foo(bar: Int)
object Foo {
  implicit val Type: ObjectType[GraphQLContext, Foo] = deriveObjectType[GraphQLContext, Foo]()
  implicit val InputType: InputObjectType[Foo]       = deriveInputObjectType[Foo]()
  implicit val Dec: Decoder[Foo]                     = deriveDecoder[Foo]
}

is it possible in any way to store this boilerplate in a superclass such that I can just extend Foo and get the extra stuff automatically?

I figured it might be possible with classTags (to get around type erasure) but no avail:

case class Foo(bar: Int) extends Bar[Foo]
class Bar[T : ClassTag] ()
object Bar {
  implicit val Type: ObjectType[GraphQLContext, T] = deriveObjectType[GraphQLContext, T]()
  implicit val InputType: InputObjectType[T]       = deriveInputObjectType[T]()
  implicit val Dec: Decoder[T]                     = deriveDecoder[T]
}
sinanspd
@sinanspd
Hey guys,
What is the best way to resolve a query into a external http call to a Rest api?
Yann Simon
@yanns
Hi community, I'd need some help to open and review pull requests on the temporary organization: https://github.com/sangria-graphql-org. For example, for each project, we'd need one PR to update sbt-coverage and the scala 2.13 version at the same time.
Sebastian Bruckner
@Sebruck

Cheers!

Could anyone PTAL at my PR? sangria-graphql-org/sangria-relay#10

Would it be possible to get a hotfix release for this? It is a blocker for us to go live.

Thx a lot!!! ❤️