by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
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.
I'm midway through building my API and interfaces were changed in sangria 2 and as there is no documentation I'm unsure how to use them
If anyone has any pointers on how to extend/use interfaces or has a github they can share it would be appreciated
Paul Daniels
@paulpdaniels
@will08rien for our sangria-based services we rolled our own federation internally because it required changes to the marshaller, for anything in the ZIO realm we use caliban though.
Will O'Brien
@will08rien
Thanks @paulpdaniels!
joshhidley
@joshhidley
@yanns We got streaming working , but only if we expose our query as a subscription. Has anyone had success using a streaming execution scheme, but with a normal query? This documentation suggests it's possible: https://sangria-graphql.org/learn/#alternative-execution-scheme
Yann Simon
@yanns
I've only used it with subscriptions. So I cannot say more.
joshhidley
@joshhidley

I've only used it with subscriptions. So I cannot say more.

OK thanks. Still looking for help in case anyone else has done this.

Justin Reeves
@justinallenreeves
We have some objects nested together and are trying to figure out defaults for Seq[T] in mutations where the Argument's type is the product of the deriveInputObjectType macro on the top type
It seems we have to wrap it in Option and OptionType but that means a Option[Seq[T]] which is kind of a pain
Is there a better way that results in not having our API consumers pass empty arrays?
Justin Reeves
@justinallenreeves

What do you do in Sangria if you want to provide some kind of validation like an argument must match a pattern or condition?
like if I'm

mutation updateFooStatus($fooId: FooId!, $status: String!) {
   updateFooStatus(fooId: $fooId, status: $status)
}

and status must be either "An Apple", "A Banana", "A Carrot"?
I can't make them enums because I need the the API to return "An Apple"

a contrived example
Justin Reeves
@justinallenreeves
I think I found the answer in ScalaAlias[Fruit, String]
Justin Reeves
@justinallenreeves
It worked!
Made a new violation for it, so it looks like a string, acts like a string, but behaves like the sealed trait + case objects it is underneath the hood
Parth Desai
@parth-code
Hi! I'm starting out with Sangria again. I'm not quite an advanced Scala developer, and I find the documentation quite vague and difficult to follow. Are there links to tutorials or examples which I can use to understand this better?
kamisama-rney
@kamisama-rney
@here Hi, I'm starting on my first production use of Sangria to create my company's first GraphQL API. Looking at the API documentation it appears there are many ways to describe a schema. What approaches are people using? The DSL, Annotations, Introspection???
My API design does support a large number of parameterized fields.
Erik
@erikdstock
Hi @parth-code and @kamisama-rney - I'm in a similar situation to you two, actually picking up a sangria schema that has been mostly frozen for the past 2 years due to these issues. Maybe we will figure things out together.
Parth Desai
@parth-code
Sounds like a plan @erikdstock
Vladislav Golub
@vagola

Type name 'X' is used for several conflicting GraphQL ObjectTypes based on different classes.

Is there any options to disable this check?

Mesut Yiğit
@mesutyigit
Is there anyone resolve this issue. This throw evere recompile the project.
[warn] [E-1] an unexpected type representation reached the compiler backend while compiling GraphQLTypes.scala: (marginChar: Char): String <and> (): String. If possible, please file a bug on https://github.com/scala/bug/issues. [error] [E-1] Error while emitting GraphQLTypes.scala [error] (marginChar: Char): String <and> (): String (of class scala.reflect.internal.Types$OverloadedType) [info] Legend: Ln = line n, Cn = column n, En = error n [error] (Compile / compileIncremental) Compilation failed [error] Total time: 3 s, completed Jul 14, 2020, 1:00:34 PM