question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatic object derivation for complex types

See original GitHub issue

Hi,

If I have a case class with complex types, e.g…

case class IndexComponentDb(id: String, name: String, weight: Double)
case class ShareClassMetaDb(
                             id: UUID,                             
                             countriesOfSale: Set[String],
                             status: String,
                             benchmarks: List[IndexComponentDb],
                             [...])

and then do automatic object derivation

val ShareClassType: ObjectType[ShareClassModel.type, ShareClassMetaDb] = {
    deriveObjectType[ShareClassModel.type, ShareClassMetaDb](
      ObjectTypeName("ShareClass"),
      ObjectTypeDescription("A share class."),
      ExcludeFields("id"))
  }

then these kinds of errors appear:

Can't find suitable GraphQL output type for Set[String], 
Can't find suitable GraphQL output type for List[IndexComponent] 

Once we have GraphQL types for the base types, in this case, String and IndexComponent, can’t Sangria automatically derive List’s and Set’s of them?

I can define a GraphQL output type for Set[String] but it doesn’t make much sense… so I think I’m probably missing something.

So how does one provide an output type in these kinds of cases?

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
kflorencecommented, May 7, 2019

Just ran into this. Might be nice to mention somewhere in the README a list of gotchas like this to save people some time.

0reactions
meddullacommented, May 8, 2017

Sorry for the long delay but been on holidays. That link provided some useful clues on how to solve this, so thanks 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatic Type Class Derivation with Shapeless — Part One
What I wanted was a library that would take a case class and automatically derive a parser for me at compile time. Ideally...
Read more >
Type Class Derivation - Scala Documentation
Type class derivation is a way to automatically generate given instances for type classes which satisfy some simple conditions. A type class in...
Read more >
Automatic differentiation - Wikipedia
AD exploits the fact that every computer program, no matter how complicated, executes a sequence of elementary arithmetic operations (addition, subtraction, ...
Read more >
Automatic derivation - circe
Automatic Derivation. It is also possible to derive Encoder s and Decoder s for many types with no boilerplate at all. Circe uses...
Read more >
Schema derivation — tapir 0.x documentation - SoftwareMill
For case classes, Schema[_] values can be derived automatically using Magnolia, ... case class RecursiveTest(data: List[RecursiveTest]) object RecursiveTest ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found