by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Alexander Kruzhkov
@YOxan
Hello guys! I've been looking for any news about ability of replacement scala's Future with IO (cats-effect) or smth else (maybe ZIO), but haven't found any info yet. Is there any plan on that?
Mariusz Nosiński
@marioosh
@schleumer AFAIR I did, do you have any issues?
Wesley Schleumer de Góes
@schleumer
@marioosh no issues at all, do you have any code on github? I'm implementing it, but i'm not confident at all :sweat_smile:
Wesley Schleumer de Góes
@schleumer
i'll make an apollo server with nodejs then i will replicate its behaviours on akka-http, i'm still confused with some messages and how its handled/sent
Ghost
@ghost~5563dbb315522ed4b3e0ef4e
Is there any function that can convert sangria Document (the result of graphql macro) into a JSON?
I've tried QueryRenderer.render(graphqlMacro, QueryRenderer.Compact) but it doesn't generate a query like it comes from a client. I'm trying to run an integration test
Wesley Schleumer de Góes
@schleumer
@jama707, do Document.source helps you?
Wesley Schleumer de Góes
@schleumer
image.png
Asaf Ary
@asafary
Question regarding profiling of queries:
We want to add an "explain" query which will provide insight on the internal federation logic to the client
This is very useful for profiling and optimizing a query (similar to SQL)
Because of the distributed nature of the query it doesn't follow the same schema as what is being returned by the "data" field and it doesn't match the "errors" field. Those are the only 2 fields in the official GraphQL spec...
Did anyone implement an extension to the schema for additional metadata in the response? What would be the best way to do that in Sangria?
Wesley Schleumer de Góes
@schleumer
@asafary you could follow the middleware pattern, i don't know how exactly implement what you ask, but you can use this as template: https://gist.github.com/schleumer/b6340b3c3c997ddff427689e3177eaa3 it's the Apollo Tracing implementation on Sangria
Mariusz Nosiński
@marioosh

@asafary add sangria-slowlog to the dependencies libraryDependencies += "org.sangria-graphql" %% "sangria-slowlog" % "0.1.8" and attach the provided middleware extension to the executor

Executor.execute(schema, query,
  middleware = SlowLog(logger, threshold = 10 seconds) :: Nil)

It will respond with some kind of profiliing info.. I hope it helps, if not, it's a good base to make your own profiler which will cover your needs... :)

Asaf Ary
@asafary
@schleumer thanks for the example, I wasn't aware of the MiddlewareExtention option
Kyle H
@khoberg
@yanns, are you still waiting on @kirach before publishing a new version?
Yann Simon
@yanns
@khoberg He does not seem to have time for this right now. Here is the new version: https://github.com/sangria-graphql-org/sangria/releases/tag/v2.0.0-M4
Wesley Schleumer de Góes
@schleumer

@travisbrown https://github.com/schleumer/sangria-ambiguous-reference

You know if this still a thing? Would help if i create an issue about it?

Richard Ney
@rney_home_twitter
I'm about to start a project to put a bunch of REST APIs behind a GraphQL API service. I'd like to have the GraphQL service pull the schema definitions of the individual APIs from either Swagger or JSON schema definitions and then defined the links and common objects in the GraphQL service. Has anyone done that with Sangria?
Matthew Tovbin
@tovbinm
Howdy folks, where does the latest "org.sangria-graphql" %% "sangria" % "2.0.0-M4" code live?
(It seems that the main repo hasn't been update for sometime already - https://github.com/sangria-graphql/sangria)
johnw
@johnw
What sort of issues would using subscriptions like one-off async queries create? (Say there's a subscription definition: theThings(filters). Client subscribes to it with some set of filters. Initial results somehow get streamed right away, then more records as they become available.) Is this even possible? Is there a way to tear down subscriptions automatically somehow? I feel like I may be thinking of subscriptions all wrong...
johnw
@johnw
I should clarify: this is a multitenant app, and filter combinations are nearly endless. This means that if I have frontend create a subscription for every query, there will be a huge number of active subscriptions at any given time. (For each query, we'll create a subscription for theFunc(customerId, fairly unique set of filters))
ale222
@ale222

Hi all, does anyone have an answer for this question asked a while ago?

hi all, I'm trying to implement Pagination with Sangria, so I was considering to use a structure like this:

  case class ConnectionModelEdge[T](
      node: T,
      cursor: UUID,
  )
  case class ConnectionModelPageInfo(
      endCursor: UUID,
      hasNextPage: Boolean,
  )
  case class ConnectionModel[T](
      totalCount: Int,
      edges: List[ConnectionModelEdge[T]],
      pageInfo: ConnectionModelPageInfo,
  )

in other words, any List[Node] Queries should become ConnectionModel[Node], ie. ConnectionModel[User]. But the problem is I don't know how to use generics with deriveObjectType. Even if I created separate implicit val for each and every type I used (ie. deriveObjectType[ConnectionContext, ConnectionModel[User]]), Sangria rises an error: Error:(32, 67) Can't find suitable GraphQL output type for T. If you have defined it already, please consider making it implicit and ensure that it's available in the scope. deriveObjectType[ConnectionContext, ConnectionModelEdge[User]]( Error:(32, 67) not enough arguments for method implicitly: (implicit e: sangria.macros.derive.GraphQLOutputTypeLookup[T])sangria.macros.derive.GraphQLOutputTypeLookup[T]. Unspecified value parameter e. deriveObjectType[ConnectionContext, ConnectionModelEdge[User]](

Yann Simon
@yanns

I'm very happy to share with you the first RC for the 2.0.0 release.
https://github.com/sangria-graphql-org/sangria/releases/tag/v2.0.0-RC1

If we have no severe issues with it, it will become the 2.0.0 release.

zvuki
@zvuki_twitter
:wave: I am wondering if something like Transport-level batching is possible with Sangria. Specifically, I am looking for ways I can optimize query execution (using deferred resolution) across N queries without a need to merging them into one. Thanks!
Mikkel Storgaard Knudsen
@MikkelStorgaard
Is there any way to pass extra parameters with a DeferredResolver or a Fetcher?
The data I need to resolve is partly retrieved from an external service, but I need to pass an authtoken along to this service
It doesn't seem like passing Seq((authToken, Seq(ids)) is the right solution
Kyle H
@khoberg
@MikkelStorgaard I haven't worked with DeferredResolvers, but it looks like they're a class that you define, in which case that class can take the authToken in the constructor assuming you have authToken at time of construction. From example in docs, something like:
class FriendsResolver(val authToken: AuthToken) extends DeferredResolver[Any] {...}
Yann Simon
@yanns

@MikkelStorgaard You can pass an AuthContext:

object DeferredReferenceResolver extends DeferredResolver[AuthContext] {
  def resolve(deferred: Vector[Deferred[Any]], ctx: AuthContext, queryState: Any)(implicit ec: ExecutionContext): Vector[Future[Any]] = {

and give the DeferredReferenceResolver to the Executor.

Mikkel Storgaard Knudsen
@MikkelStorgaard
@khoberg , @yanns If I go with that, do I then have to redo the Fetchers I have now? and implement them inside Resolve?
At the moment I am just using DeferredResolver.fetchers(fooFetcher, barFetcher, ...) who has a context already.
But that context is my GraphQLService because I am using the services exposed therein to do my calls
Mikkel Storgaard Knudsen
@MikkelStorgaard
Could I have ctx: (Option[AccessToken], GraphQLService)?
Yann Simon
@yanns
Your fetchers can also use the context. Ex:
      Fetcher.relCaching(
        (ctx: AuthContext, ids: Seq[UUID]) => {
Mikkel Storgaard Knudsen
@MikkelStorgaard
@yanns In this example, are you still making a CustomDeferredResolver extending DeferredResolver and then initializing with CustomDeferredResolver.fetchers(...), or are you just using DeferredResolver.fetchers(...)
Mikkel Storgaard Knudsen
@MikkelStorgaard

@yanns https://pastebin.com/WbnyvFqC I currently have fooFetcher , but I need to be able to have fooFetcherBetter. however I don't know how to get the implicit accessTokenOption into the fetcher from here.

(disclaimer; I have a background in functional programming, but I have only used Scala/Sangria/... for a bit more than a month, so there might be some Scala features here that I am not aware of.)

Yann Simon
@yanns
Your schema must use the AuthContext (ex: schema: Schema[AuthContext, Unit])
Mikkel Storgaard Knudsen
@MikkelStorgaard
Okay, so far so good :)
@yanns could I do
def fooFetcher()(implicit accessTokenOption: Option[AccessToken]) = Fetcher( (ctx: GraphQLService, ids: Seq[Ids]) => ctx.listFoos(ids), )(HasId(_.id))?
that way I won't be messing with the ctx
Yann Simon
@yanns
No, the fetcher is instantiated once per schema. You have to use the context to propagate data related to the request
Mikkel Storgaard Knudsen
@MikkelStorgaard
heck
@yanns So I should probably make room for some authorisation result or the token itself in my GraphQLService, right?
Mikkel Storgaard Knudsen
@MikkelStorgaard
In regards to GraphQLService and it being the context, I think we (my senior and I) have been "holding it wrong" until this point.
I think I have a clear idea of what to do now, so thank you so much for your help
Erik
@ErikHedblom
@yanns Can we have another release? I'm eager to start using these changes sangria-graphql-org/sangria#59 =)
Yann Simon
@yanns
Hi everyone. I've finally received the rights for the original github sangria organization.
All changes from the temporary fork are now replayed on the original repositories.
And I'm happy to release the v2.0.0-RC2: https://github.com/sangria-graphql/sangria/releases/tag/v2.0.0-RC2
yiksanchan
@YikSanChan
@yanns great news!
Yann Simon
@yanns
If you want to help the sangria ecosystem, please read https://github.com/sangria-graphql/sangria/issues/446#issuecomment-623075358
Paul Daniels
@paulpdaniels
I'm curious if anyone else got federation working? I wrote some extensions to get it working for one of our internal projects, but it required creating a custom input unmarshaller (because of the _Any input).
Bek
@jbek7
Hello, is there any way to generate Scala stubs from a Graphql SDL, schema.graphql?