by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
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?
Justin Reeves
@justinallenreeves
Do you have any resources for learning GraphQL, especially in the concept of moving exisiting REST API to GraphQL?
The Sangria documentation is great but there's a level of familiarity I think it assumes that I lack.
sinanspd
@sinanspd
@justinallenreeves have you looked at graphQL's site? https://graphql.org/
snabar
@snabar
Hi! I have a dynamically generated type, and I'd like to modify its fields at a later point in the code. Are there any recommendations on the best way to do this?
Mandeep Raj Shrestha
@mandeeeep

Hi, Has anyone tried using the class generated by scalapb(json4s) with the InputObjects for sangria.
Even after importing the libs sangria.marshalling.json4s.native._
scalapb generates the reads and we can retrieve the Reader , if needed and provide it implicitly., but even after doing so we still get the "Please consider defining an implicit instance of FromInput for it." error

sangria-graphql/sangria#202 , do we still need to explicitly create FromInput as stated in this issue

Léonard Marques
@keuhdall
Hello everyone, sorry to bother you but I have a question regarding Sangria: I recently started a personal project and was planning to use Sangria. The thing is my project is in Scala 2.13 and I don't see 2.13 artifacts for version 1.4.2, should I consider using 2.0-RC2 instead ? And how stable is this version ? Thank you!
codepusher313
@codepusher313
Is there an example of using Fetchers for something other than the primary id? I have an object that, in addition to its primary id, contains a unique id used for integration with a 3rd party service. In some cases I need to lookup objects by those 3rd-party ids, but when I do that with a Fetcher I get "Fetcher has not resolved non-optional ID" since the primary ids of the returned objects do not match the given 3rd-party ids.
Is there some way for me to say which id field on the object it should compare to for this one Fetcher?
codepusher313
@codepusher313
I see, I can pass it an explicit HasId to the Fetcher that overrides the id field for that fetcher. That worked.
joshhidley
@joshhidley
We're trying to use ExecutionScheme.Stream without using Subscriptions. Is that possible?
We just have a large amount of data we want to stream, but don't want to implement subscriptions.
Justin Reeves
@justinallenreeves

Trying to figure out how to make input fields that have defaults defined optional?

  implicit val CompanyFilterCriteriaType = 
    deriveInputObjectType[CompanyFilterCriteria](InputObjectTypeName("CompanyFilters"))
  implicit val CompanySortCriteriaType = 
    deriveInputObjectType[CompanySortCriteria](InputObjectTypeName("CompanySortCriteria"))
  implicit val CompanySortQueryType = 
    deriveInputObjectType[CompanySortQuery](InputObjectTypeName("CompanySort"))

  val CompanyFiltersArg =
    Argument("filters", ListInputType(CompanyFilterCriteriaType), defaultValue = Seq.empty[CompanyFilterCriteria])
  val CompanySortArg: Argument[CompanySortQuery] =
    Argument("sort", CompanySortQueryType, defaultValue = CompanySortQuery(Seq.empty[CompanySortCriteria]))

looks like in the schema

filters: [CompanyFilters!]! = []
sort: CompanySort! = {fields: [], direction: Ascending}

Is the only way to change that Argument to a Argument[Option[Seq[CompanyFilterCriteria]] as well as the queried service to accept an Option[Seq[CompanyFilterCriteria]] and a default Seq.empty[CompanyFilterCriteria])
even with sort: CompanySort! being flagged as non-nullable, it uses the default if I don't supply it in the query.

It's functional and uses defaults when the variables are missing but not when they're null so I'm worried it's confusing to a user.