Comments (2)
Hi, thanks for asking! This is definitely a challenge I faced as well. Just as you described, at this stage we don't have concrete instances, so it's impossible to determine which objects would be returned as a result of an execution.
On the other hand we have the list of possible sub-types, which is known beforehand. My solution to this issue is pretty simple: i just take into consideration all possible fields of all possible sub-types. It's done here:
When you think about it, it's actually very suitable behavior in most of the cases. The are many different ways to represent class hierarchy on DB Level. In relation DB, for instance, it can be a big table with all possible fields. In this case it would be correct to project all possible fields, that are present in GraphQL selection-set. It's just some of them will have null values if particular row is of different type. You can also represent it as several tables (one table for each concrete class). But it's effectively the same, since you most probably will use outer joins at query time. NoSQL databases are also not that much different. In mongo query, for instance, I can provide a list of all possible projections that are interesting for me. If some document does not have particular projected field, the result simply will not include it.
from sangria.
I will close this issue for the moment being, but if you would like to further discuss this or any other feature, please feel free to reopen it.
If you want, we can also continue this discussion in gitter chat: https://gitter.im/sangria-graphql/sangria
from sangria.
Related Issues (20)
- It is impossible to override an built-in scalar
- Decoding failure HOT 9
- Unnecessary implicit conversion while using experimental catseffect `AsyncValue` HOT 2
- Change context object
- Support OneOf on Input Objects HOT 1
- Website is down HOT 1
- Looking for help / maintainers
- Main documentation seems to not link to scaladoc / javadoc HOT 1
- Build a Sangria Steward
- Scala 3 Derive Macro Compiler Error HOT 9
- Scala 3: Exception returning Future values from GraphQL Endpoint HOT 1
- [scala3] sangria-relay HOT 1
- Error behavior when `name` argument to ObjectType constructor contains a space HOT 5
- `Context.arg` Wraps Optional Arguments inside another Option HOT 4
- Query/Schema validation for default values on object type field arguments not captured (ValueOfCorrectType rule) HOT 2
- Using `Option` in fields fails in the `None` case HOT 8
- `ListInputType[T]` extending `InputType[Seq[T]]` HOT 5
- support @deprecated on argument and input field HOT 1
- The custom scalars do not parse underlying model HOT 3
- Long type user input coercion missing implicit conversion from java.math.BigDecimal HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sangria.