by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Mikkel Storgaard Knudsen
@MikkelStorgaard
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.

Daave
@Yomanz
Hey!
image.png
I have this field on my graphql schema
But when i have the Seq[X] there
Error:(65, 69) Seq[TextMessagePayload]: Field list is empty deriveObjectType[SecureContext, Seq[TextMessagePayload]](),
Is there another type of iterable I should be using > Seq?
Daave
@Yomanz
ListType
oops
Léonard Marques
@keuhdall
Mh, any recommendation regarding the Sangria version I should use with Scala 2.13 ? :/
Sorry to bother you with that, but I'm really not sure what's the best option here :(
sinanspd
@sinanspd
@keuhdall anything past 2.0.0 is compatible with Scala 2.13
Léonard Marques
@keuhdall
Thanks! Regarding stability, won't there be any issues since 2.0 is still in release candidate ?
sinanspd
@sinanspd
I mean... no one can guarantee that. It has been less than 2 months since the prerelease has been published and I am sure a number of people adapted it. I wouldn't recommend using a pre-release in production but one of the goals of pre-release is to find issues and fix them :) Plus, if you are set on using Sangria you really have no other option, using a 2.12 version with 2.13 will give you a lot more headaches
Léonard Marques
@keuhdall
I'll give RC2 a try then! Thank you!
Yann Simon
@yanns
Version 2.0.0 is now out: https://github.com/sangria-graphql/sangria/releases/tag/v2.0.0
That was a long way. Thx a lot to all who helped!
Justin Reeves
@justinallenreeves

Is there a difference between a input being nullable and have a default value baked into to graphQL or Sangria. Never used one without the other, so getting used to things.

I have a lot of APIs I'm querying that supply defaults but don't take Options, so the derive macros turn this in non nulls in the introspection schema.

but to me they're not required...I provide a default if my api consumers don't give me a value.
Will O'Brien
@will08rien
Hola 👋. Just wondering what people do for stitching/federation in this channel. Apollo federation seems to be latest and greatest but support in scala seems limited. Any pointers please?
Daave
@Yomanz
I noticed that v2.0.0 was out now but there is no documentation for it.